I have an application where the first view is a login screen, and the username and password is used for authentication all around the application. If something go wrong in the authentication process, the user will be thrown back to the login screen, but if the problem occurs when the user press the back button in the navigation bar, the application is showing the login screen correct, but the navigation bar will show the buttons from the view it was supposed to show.
Example: If a user press the back button on View B, and the application is supposed to show View A, but something went wrong, the application will show the login screen, but the navigation bar is the one from View A.
I have tried a couple of things, but the thing that came closest was:
In the ViewWillDisappear for View B:
NSArray * nc = [self.navigationController viewControllers];
[self.navigationController popToViewController:[nc objectAtIndex:0] animated:YES];
And it gave the result discribed above.
In your LoginController override the viewWillAppear: methods and set the navigation bar button as you want :
If you don’t use ARC remember to add autorelease to the leftBarButton Item :