在呈现新的ViewController之后Deinit UITabBarController

时间:2017-08-28 20:33:03

标签: ios swift uiviewcontroller uitabbarcontroller deinit

我有一个用户可以登录的应用。如果用户启动了应用并且已经登录,则rootViewController设置为我的自定义UITabBarController但是当用户未登录时rootViewController设置为LoginVC(View Controller)。我的问题是,当用户注销时,应该显示LoginVC并且应该取消初始化TabBar。

我试过了:

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

这样的事...... 我可以提供LoginVC,但是当我拨打self.tabBarController?.dismiss时 LoginVC被取消而不是TabBarVC

非常感谢任何帮助

1 个答案:

答案 0 :(得分:2)

rootViewController设置为LoginVC会更好。对UITabBarController的引用将丢失,并且将取消初始化。

在VC上调用dismiss不会忽略该VC。它驳回了它所呈现的VC:

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

  

取消视图控制器以模态方式显示的视图控制器。

相关问题