导航控制器不能正常工作

问题描述 投票:0回答:2

在过去的两个月里,我一直在使用下面的代码快速访问另一个VC,我一直在学习。

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

但现在因为我想在另一个项目中再次使用它,它不起作用!有人有任何想法吗?

swift uiviewcontroller uinavigationcontroller navigation
2个回答
2
投票

首先,您应该测试以确保导航控制器不是Sh_Khan所提到的nil。

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

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

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

这将导致您创建一个新的导航控制器并在其中嵌入qazxsw poi viewController,然后按下navigationController。

祝好运


2
投票

这可能是您运行此代码的vc

next

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

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

没有

因此没有推动

© www.soinside.com 2019 - 2024. All rights reserved.