swift - 导航 Controller 不工作可疑

标签 swift uiviewcontroller uinavigationcontroller navigation

在过去的 2 个月里,我一直在使用下面的代码去 swift 的另一个 VC,我一直在学习 swift。

let next = self.storyboard?.instantiateViewController(withIdentifier: "VerifyVC") as!
self.navigationController?.pushViewController(next, animated: true)

但是现在因为我想在另一个项目中再次使用它,所以它不起作用! 有人知道吗?

最佳答案

首先你应该测试以确保 navigationController 不是 Sh_Khan 提到的 nil。

如果它是零那么你可能想要添加它。

 let next = self.storyboard?.instantiateViewController(withIdentifier: "VerifyVC") as!

let navigationController = UINavigationController(rootViewController: next)
self.present(viewController: navigationController, animated: true, completion: nil)

这将导致您创建一个新的导航 Controller 并将 next viewController 嵌入其中,然后推送导航 Controller 。

祝你好运

关于swift - 导航 Controller 不工作可疑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52136714/

相关文章:

iphone - 如何获取插入我当前 View 的上一个 View Controller

iphone - 子类化 UIToolbar 的正确方法

ios - 带有在另一个类中声明的 pushViewController 的 UIButton

iphone - 如何设置模态视图 Controller 的标题栏标题?

ios - 我想在快速代码中访问第二个 View Controller 中的 var

ios - 将字典保存到文件并读回

swift - 为什么我的自定义转换不适用于我的导航 Controller ?

ios - 解析 XLSX 期间找不到 Xcode 文件错误

ios - 尝试浏览由 swift 应用程序创建的简单 .sqlite 文件?

swift - 使用按钮重置 UNTimeIntervalNotificationTrigger