简体   繁体   English

在不同的导航中从一个视图 Controller 弹出到另一个视图 controller

[英]Pop from one View Controller to another in a different navigation controller

I am trying to pop a view controller VC1 from one navigation controller NC1 to another view controller VC2 in another navigation controller NC2. I am trying to pop a view controller VC1 from one navigation controller NC1 to another view controller VC2 in another navigation controller NC2.

I am using the VIPER architecture thus routing between different view controllers in different navigational hierarchies requires that I must switch to the root of the navigation controller I want to present.我正在使用 VIPER 架构,因此在不同导航层次结构中的不同视图控制器之间进行路由要求我必须切换到我想要呈现的导航 controller 的根目录。

So the issue here is that, after navigating to the view controller VC2 of the second navigation controller NC2, I want to go back to the first view controller VC1 in the first navigation controller NC1. So the issue here is that, after navigating to the view controller VC2 of the second navigation controller NC2, I want to go back to the first view controller VC1 in the first navigation controller NC1.

I have tried the following:我尝试了以下方法:

 self.navigationController?.popViewController(animated: true)

 navigationController?.dismiss(animated: true, completion: nil)

 view.window?.rootViewController?.dismiss(animated: true, completion: nil)

 self.navigationController?.popToRootViewController(animated: true)

but none of them worked for me.但没有一个对我有用。 Any ideas?有任何想法吗?

Please Try this codes:请尝试以下代码:

let viewControllers = self.navigationController?.viewControllers

for vc in viewControllers! {

   if vc is VC1 {
      self.navigationController?.popToViewController(vc as! VC1, animated: true)
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从一个视图控制器弹出到另一个视图控制器 - How to pop from one view controller to another view controller 如何在其他导航控制器中弹出视图? - How to pop back to a view in a different navigation controller? 在另一个导航控制器上弹出导航控制器 - Pop navigation controller on another navigation controller 如何将数据从一个视图控制器传递到导航控制器中嵌入的另一个视图控制器 - How to pass data from one view controller to another view controller which is embedded in navigation controller 弹出以查看导航堆栈中的控制器 - Pop to view controller in navigation stack 通过导航栏颜色的变化从一个视图控制器转换到另一个视图控制器 - Transition from one view controller to another with a change in colour of navigation bar 将一个视图控制器导航到另一个 - Navigation one view controller to another getting 将viewcontroller从另一个导航Controller弹出到另一个viewcontroller - Pop viewcontroller to another viewcontroller from another navigation Controller 推送/弹出视图控制器,带有导航栏,来自View Controller,不带导航栏 - Push / Pop View Controller With Navigation Bar from View Controller Without Navigation Bar 如何弹出到其他视图控制器 - how to pop to different view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM