2017-05-12 59 views
-1

我有一個帶有多個控制器的MainTabBarController。 在我的FirstTabViewController(嵌入UINavigationController)我推送到另一個視圖控制器,如:navigationController?.pushViewController(secondViewController, animated: true)解除Modal的視圖控制器

在此控制器,我已經表現出一個模式視圖控制器,如:

let vc = self.storyboard!.instantiateViewController(withIdentifier: "SomeViewController") as! SomeViewController 

vc.modalPresentationStyle = .overFullScreen 
vc.modalTransitionStyle = .coverVertical 

let nav = UINavigationController(rootViewController: vc) 
self.present(nav, animated: true, completion: nil) 

而在SomeViewController,我已經解僱該控制器這樣的:self.dismiss(animated: true),但它自動彈出到根視圖控制器(FirstTabViewController)。

我的問題,爲什麼?

謝謝。

回答

2

目前SomeViewController在您當前的控制器上不在navigationController上。

這麼改線:

self.navigationController?.present(nav, animated: true, completion: nil) 

要:

self.present(nav, animated: true, completion: nil) 
+0

感謝。我試過了,但它對我不起作用:/ – Idnext

+0

@Idnext當你這樣呈現時,當你關閉'SomeViewController'時發生了什麼? –

+0

'FirstTabViewController'出現...像一個popToRoot效果 – Idnext

0

_ = navigationController .popViewController(動畫:真)

dismiss(animated: true, completion: nil)