use*_*374 7 navigation iphone uinavigationcontroller ios swift3
我的主视图控制器是 Tabbarcontroller
所以,我想首先关闭呈现的视图控制器,然后我想弹出我以前推送的控制器
这是我的导航流程
From Tabbarviewcontroller
1- let aVC = self.storyboard?.instantiateViewController(withIdentifier: "a") as! OrderListingViewController
self.navigationController?.pushViewController(aVC, animated: true)
From A viewcontroller
2- let bVC = self.storyboard?.instantiateViewController(withIdentifier: "b") as! OrderListingViewController
self.navigationController?.pushViewController(bVC, animated: true)
From B viewcontroller
let cVC = self.storyboard?.instantiateViewController(withIdentifier: "c") as! RejectOrderViewController
cVC.providesPresentationContextTransitionStyle = true
cVC.definesPresentationContext = true
cVC.modalPresentationStyle=UIModalPresentationStyle.overCurrentContext
self.tabBarController?.presentVC(cVC)
Run Code Online (Sandbox Code Playgroud)
所以从 C Viewcontroller 当我解散我想显示 Tabbarviewcontroller 或 (A) ViewController
您必须ViewController C通过以下方式驳回。
self.presentingViewController将给出前一个视图控制器对象。
移动到根视图控制器
let presentingVC = self.presentingViewController
self.dismiss(animated: true) {
presentingVC?.navigationController?.popToRootViewController(animated: false)
}
Run Code Online (Sandbox Code Playgroud)
移至上一个控制器
如果您需要以前的视图控制器而不是根视图控制器,那么您只需使用 popViewController
let presentingVC = self.presentingViewController
self.dismiss(animated: true) {
presentingVC?.navigationController?.popViewController(animated: false)
}
Run Code Online (Sandbox Code Playgroud)
移动到特定的视图控制器
let presentingVC = self.presentingViewController
self.dismiss(animated: true) {
if let destinationVC = presentingVC?.navigationController?.viewControllers.filter({$0 is <Your Destination Class>}).first {
presentingVC?.navigationController?.popToViewController(destinationVC, animated: false)
}
}
Run Code Online (Sandbox Code Playgroud)
<Your Destination Class>替换为您的目标类名称。
| 归档时间: |
|
| 查看次数: |
5135 次 |
| 最近记录: |