When a user run my app for the first time a LoginViewController appears. Once he is logged in, I present a ModalViewController with all the stuff of the app. If the user want to log out, I dismiss the modal view, showing the LoginViewController again.
The problem comes if the user runs the app when is already logged. In the self.window.rootViewController, I set directly the main view of the app (embebed in a UITabBarController), so if the user want to log out, I don’t know the way to “dismiss” the view and show the LoginViewController.
SCENARIO:
- User no logged yet: LoginViewController -> (Log in) ->
UITabBarController-> (Log out) -> LoginViewController. - User already logged:
UITabBarController-> (Log out) -> LoginViewController.
I think there must be a simple way to do this, because it is a very normal behavior in an app with a login system, but I haven’t found a clean way to do it.
Try following way :
After Login, dismiss LoginViewController. Again while logout present LoginViewController modally on tabBarViewController as above.