【问题标题】:navigation controller is not working suspiciously导航控制器没有可疑地工作
【发布时间】:2018-09-02 11:45:11
【问题描述】:

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

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

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

【问题讨论】:

    标签: swift uiviewcontroller uinavigationcontroller navigation


    【解决方案1】:

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

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

     let next = self.storyboard?.instantiateViewController(withIdentifier: "VerifyVC") as!
    
    let navigationController = UINavigationController(rootViewController: next)
    self.present(viewController: navigationController, animated: true, completion: nil)
    

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

    祝你好运

    【讨论】:

      【解决方案2】:

      很可能是你运行这段代码的vc

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

      inside 没有嵌入到 navigationController 中,所以这个

      self.navigationController
      

      因此没有推送发生

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-15
        • 1970-01-01
        • 2013-07-29
        • 1970-01-01
        • 2011-10-24
        • 1970-01-01
        相关资源
        最近更新 更多