My problem:
My app requires a user to be logged in, so the first view I show is a login view. If we are logged in, then we show the app view, which is a tab bar controller. One of these tabs is account info + logging out. On logging out, I want to go back to the the login screen.
My solution:
The root view is a navigation controller, which holds the main view. The main view is transparent, just says are you not logged in? Push the account screen onto the stack. If logged in, push the tab controller view onto the stack. Each tab in the tab controller is a navigation controller. Clicking on the account tab pushes the account view on the account view onto the stack. The account view has a logout button, which pops up 2 views (and doesn't work):
// Go to main view (2 views up) to show default login screen (as we won't be logged in anymore)
UINavigationController *navController = self.navigationController;
[navController popViewControllerAnimated:NO];
[navController popViewControllerAnimated:YES];
What I think is the problem:
The navigation controller that I have on the top level is not the same as the lower level navigation controllers in the tab controller.
My problem seems fairly typical, but my solution seems really clunky. This can't be the best way to do it! Any advice?