ios - 如何从导航堆栈中删除 ViewController 并且没有返回它的选项-Swift

标签 ios swift uinavigationcontroller

我有一个登录页面,如果登录成功,用户将被带到登陆 viewController(VC)。我有一个导航 Controller 。我弹出登录 VC 并插入登陆 VC。我遇到的问题是登录 VC 仍然存在于堆栈中,如导航 Controller 上的左按钮所示,它将您导航回登录页面。如何从堆栈中完全删除登录 VC,以便导航 Controller 无法在用户登录后导航回它?

 self.navigationController?.popViewController(animated: true)

 let landingPage = self.storyboard?.instantiateViewController(withIdentifier: "landingPage") as! 
 LandingViewController

 self.navigationController?.pushViewController(landingPage, animated: true)

最佳答案

您可以使用 setViewControllers 方法来设置堆栈,如下所示:

self.navigationController?.setViewControllers([landingPage], animated: true)

您也不需要先弹出登录 View Controller 。

关于ios - 如何从导航堆栈中删除 ViewController 并且没有返回它的选项-Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47334655/

相关文章:

ios - 如何使用 Ionic 更改 iOS 上进度条的样式?

ios - 更改 TextView 文本时保留文本样式

ios - 后退按钮未显示在导航 Controller 中

ios - 启动 UIApplication.shared.open 后重定向回应用程序

ios - collectionView 中的异常(_ :layout:sizeForItemAt:) when accessing layout. collectionViewContentSize

ios - 如何在 View 出现后立即启动核心动画?

ios - 如何从 Storyboard 中的 subview (另一个 View Controller )中的按钮推送新的 View Controller

ios - 改进 Tesseract OCR 中的预处理步骤以进行实时捕获

iphone - Objective-C setImage forState :UIControlStateNormal not formatting image properly

iphone - 如何将 UIView 渲染到 CGContext