[英]Add current viewcontroller to navigationControllerStack
好的,所以我有2个VC。
从vc1我使用segue移到vc2
现在从vc2中,我想使用以下代码移至vc2
let vc = storyboard?.instantiateViewController(withIdentifier: screenId)
navigationController?.pushViewController(vc!, animated: true)
由于未将VC2添加到导航控制器堆栈,因此无法正常工作。
我想知道如何以编程方式将VC2添加到导航控制器堆栈中。 事情是,我在某些情况下使用segue,而在另一些情况下则推送视图控制器。
navigationController = nil
可能
因此,如果是这样,则需要将视图控制器嵌入到导航视图控制器中。
在这种情况下, UINavigationContoller
应该是您的根视图控制器。 请验证您的根视图控制器。
您可以尝试以下方法:
let loginVc = storyboard?.instantiateViewController(withIdentifier: screenId)
let aObjNavi = UINavigationController(rootViewController: loginVc)
let appDelegate: AppDelegate = (UIApplication.shared.delegate as? AppDelegate)!
appDelegate.window?.rootViewController = aObjNavi
执of
let vc = storyboard?.instantiateViewController(withIdentifier: screenId)
navigationController?.pushViewController(vc!, animated: true)
它可能会帮助您。 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.