2017-08-28 116 views
2

我有一個用戶可以登錄的應用程序。如果用戶啓動應用程序並且已經登錄,那麼rootViewController設置爲我的自定義UITabBarController,但是當用戶未登錄rootViewController被設置爲LoginVC(視圖控制器)。我的問題是,當用戶註銷時,應該呈現LoginVC並且TabBar應該被初始化。Deinit UITabBarController在呈現新的ViewController後

我曾嘗試:

self.tabBarController?.dismiss(animated: true, completion: { 
    self.tabBarController?.present(LoginVC(), animated: true, completion: nil) 
}) 

之類的東西......我 可呈現LoginVC但是當我打電話self.tabBarController?.dismiss 的LoginVC被駁回,而不是TabBarVC

任何幫助將是非常感謝

回答

2

最好將rootViewController設置爲LoginVC。對UITabBarController的引用將會丟失,並且它將被取消。

在VC上調用dismiss並不能解除該VC。它駁回VC它被呈現:

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss

駁回,是由視圖控制器模態呈現的視圖控制器。

+0

有沒有辦法讓這個過渡動畫? – Phyber

+2

https://stackoverflow.com/questions/7703806/rootviewcontroller-switch-transition-animation –

相關問題