在过去的 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/