【发布时间】:2021-10-03 02:29:55
【问题描述】:
我创建了一个带有故事板的自定义框架。然而,即使根视图控制器是从导航控制器嵌入的,每次我检查“self.navigationController”时它都会打印“nil”。我在这里错过了什么。
但是,我的目标是在我单击第 4 个 VC 中的按钮后弹回根 viewController。目前实现如下
我的自定义故事板如下所示。
我如何导航如下。
if let urlString = Bundle.main.path(forResource: "FAUMESDK", ofType: "framework", inDirectory: "Frameworks") {
let bundle = (Bundle(url: NSURL(fileURLWithPath: urlString) as URL))
let sb = UIStoryboard(name: "FAUMEStoryboard", bundle: bundle)
let vc = sb.instantiateViewController(withIdentifier: "MessagePriviewVC")
vc.modalPresentationStyle = .fullScreen
self.show(vc, sender: nil)
}
我尝试了下面的代码但没有用
let vc = self.storyboard?.instantiateViewController(
withIdentifier: "MyVCIdentifier") as! MessagePreviewUIViewController
self.navigationController?.pushViewController(vc, animated: true)
我试图弹回 rootVC 的方式如下(目前它不起作用,这是我需要解决方案的地方)。
navigationController?.popToRootViewController(animated: true)
我在这里错过了什么???
【问题讨论】:
标签: ios swift uinavigationcontroller