2016-09-23 98 views
0

我打開導航控制器,使用故事板中的直接導航segue或從代碼中調用segue,但仍在故事板上創建。如何正確關閉模態呈現的控制器

實施例:

self.performSegue(withIdentifier: "addNew", sender: nil) 

然後與模態過渡打開navigationController。 NC然後有幾個視圖控制器上都對他們關閉按鈕,當我點擊它,它使用關閉NC:

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

但後來當我在TabbarController不同ViewControllers之間切換或打開與推動一些其他視圖查看我得到:

Unbalanced calls to begin/end appearance transitions for 

還viewWillAppear上打開的視圖不會被調用。所以任何人都可以告訴我,如果我正確關閉NC或者有其他方法來防止錯誤。

EDIT1: 從 改變了收盤集合競價controller.navigationController .dismiss?(動畫:真,完成:無)

到self.navigationController .dismiss?(動畫:真,完成:無)剛使問題更容易。

還累:

self.dismiss(animated: true, completion:nil) 

EDIT2: 是它可能是錯誤的,打開從VC數控是數控是對的UITabBarController或只是簡單地本來就不好有NavigationControllers作爲TabbarController標籤?

+0

'self.navigationContro ...... [「不平衡調用的' –

+0

可能的複製DetailViewController「開始/結束外觀轉換」時推送多個詳細信息視圖控制器](http://stackoverflow.com/questions/9088465/unbalanced-calls-to-begin-end-appearance-transitions-for-detailviewcontroller) –

+0

@奧列格戈迪丘克不這麼認爲,辛格e如果我從未打電話給其他NC,那麼不會出現問題 – schmru

回答

2

您可能需要從控制器側關閉控制器:

// place this to the target controller, which handles you that modal view 
self.dismiss(animated: true) { 
    //completion: 
} 

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

有了這條線我可以更快地得到問題,但是謝謝您的建議 – schmru

+0

那麼,您在哪裏放置了那條線?用什麼方法? – pedrouan

+0

我替換了self.navigationController?.dismiss(animated:true,completion:nil) – schmru

相關問題