I have an app in which users can log in. If the user launches the app and is already logged in then the rootViewController
is set to my custom UITabBarController
but when the user is not logged in the rootViewController
is set to LoginVC (View Controller). My problem is that when the user logs out the LoginVC should be presented and the TabBar should be deinitialized.
I have tried:
self.tabBarController?.dismiss(animated: true, completion: {
self.tabBarController?.present(LoginVC(), animated: true, completion: nil)
})
And things like that...
I can present the LoginVC but when I call self.tabBarController?.dismiss
the LoginVC gets dismissed instead of the TabBarVC
Any help would be greatly appreciated
It's better to just set the
rootViewController
to theLoginVC
. The reference to theUITabBarController
will be lost and it will de-init.Calling
dismiss
on a VC does not dismiss that VC. It dismisses the VC it is presenting:https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss