I have three Views, Splash, Login and List.
From Splash I just wait and then Push Login View, with the Navigation Bar hidden.
In Login I Show the NavigationBar, hide the BackButton1 and add a new RightButton1, then I check if Settings.bundle "login" and "pass" are set. If so, I push List View. Otherwise I stay in the Login view waiting for the user to fill the form and press a button.
In List View I add a new RightButton2 and a new BackButton2.
The problem is that if Settings.bundle data is not null, and in Login View I quickly push List View the RightButton1 appears in List View, or no buttons appear at all, or only BackButton2 doesn't appear...
The most strange thing of all is that everything was OK and all of sudden it started to get messy.
Login View:
// Making the Navigation Bar Visible
[self.navigationController setNavigationBarHidden:NO animated:NO];
// Hiding the Back Button in THIS view (Login)
[self.navigationItem setHidesBackButton:YES];
// Inserting the Logout Button for the Next View (List)
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
initWithTitle:@"Logout"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
UIBarButtonItem* newAccountButton = [[UIBarButtonItem alloc]
initWithTitle:@"New Account"
style:UIBarButtonItemStylePlain
target:self
action:@selector(newAccountButtonPressed)];
self.navigationItem.rightBarButtonItem = newAccountButton;
[newAccountButton release];
List View
// Making the Navigation Bar Visible
[self.navigationController setNavigationBarHidden:NO animated:NO];
UIBarButtonItem* aboutButton = [[UIBarButtonItem alloc]
initWithTitle:@"About"
style:UIBarButtonItemStylePlain
target:self
action:@selector(aboutButtonPressed)];
self.navigationItem.rightBarButtonItem = aboutButton;
[aboutButton release];
Any ideas ?
UPDATE: I've tested more and it seems to me that when I quickly go from Login to List the NavigationBar doesn't have enough time to add the buttons and add the buttons and the bars in the wrong order. I've used a performSelector to make Login view wait until push List and if the Delay is like 2secs, everthing goes fine, but if it is like 0.1secs the problem appears again.
I'm usign viewDidLoad.. How can I make the Login View only push the List View after everything in it's NavigationBar is already ok? In other words, how can I make the push wait all the previous commands without a delay with fixed timing ?