Ios 导航控制嵌入在容器视图自定义序列中
我有Ios 导航控制嵌入在容器视图自定义序列中,ios,swift,uinavigationcontroller,segue,uicontainerview,Ios,Swift,Uinavigationcontroller,Segue,Uicontainerview,我有UIContainerView,里面有UINavigationController和嵌入UINavigationController的其他VC(其中7个) 所以,看起来是这样的: 在UINavigationController内的7个屏幕上,我正在调用一个弹出屏幕,该屏幕将重定向到另一个屏幕,用户可以从该屏幕执行返回到调用的VC弹出窗口的顺序 因此,用户在UINavigationController内的旅程将如下所示: 打开VC1(2,3,5,6,7)->调用弹出VC->按下按钮->打开V
UIContainerView
,里面有UINavigationController
和嵌入UINavigationController
的其他VC(其中7个)
所以,看起来是这样的:
在UINavigationController
内的7个屏幕上,我正在调用一个弹出屏幕,该屏幕将重定向到另一个屏幕,用户可以从该屏幕执行返回到调用的VC弹出窗口的顺序
因此,用户在UINavigationController
内的旅程将如下所示:
打开VC1(2,3,5,6,7)->调用弹出VC->按下按钮->打开VC4->按下导航返回按钮->返回VC1
这是我的密码:
@IBAction func didPressAuthors(_ sender: UIButton) {
self.dismiss(animated: true) {
if let navigation = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController {
let vc1 = self.storyboard!.instantiateViewController(withIdentifier: "FirstVC")
let vc2 = self.storyboard!.instantiateViewController(withIdentifier: "SecondVC")
let vc3 = self.storyboard!.instantiateViewController(withIdentifier: "ThirdVC")
let vc4 = self.storyboard!.instantiateViewController(withIdentifier: "FourthVC")
let vc5 = self.storyboard!.instantiateViewController(withIdentifier: "FifthVC")
let finalVC = self.storyboard!.instantiateViewController(withIdentifier: "Authors")
let userJourney = self.defaults.array(forKey: DefaultKeys.screenID.rawValue)
for vcName in userJourney! {
switch String(describing: vcName) {
case "FirstVC":
self.journeyVC.append(vc1)
case "SecondVC":
self.journeyVC.append(vc2)
case "ThirdVC":
self.journeyVC.append(vc3)
case "FourthVC":
self.journeyVC.append(vc4)
case "FifthVC":
self.journeyVC.append(vc5)
default:
self.journeyVC.append(finalVC)
}
}
self.journeyVC.append(finalVC)
navigation.setViewControllers(self.journeyVC, animated: true)
}
}
}
问题:
当我没有UINavigationController
内部UIContainerView
时,这段代码运行得很好,但在我添加了容器视图之后,它停止了。调用了discouse func,但什么也没有发生。我错过了什么?我应该改变VC的呈现方式吗
如果有人能帮我解决这个问题,我将不胜感激。非常感谢,祝你周末愉快 您当前的根目录不是此处的导航
if let navigation = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController {
这是一个常见的VC,导航是作为一个孩子插入的,所以试试看
if let root = UIApplication.shared.keyWindow?.rootViewController as? RootVC {
let nav = root.children![0] as! UINavigationController
您当前的根目录不是此处的导航
if let navigation = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController {
这是一个常见的VC,导航是作为一个孩子插入的,所以试试看
if let root = UIApplication.shared.keyWindow?.rootViewController as? RootVC {
let nav = root.children![0] as! UINavigationController
这就是我错过的。非常感谢您的快速响应和良好的修复!这就是我错过的。非常感谢您的快速响应和良好的修复!