UINavigationBar is getting buttons from another view
Posted
by Rafael Oliveira
on Stack Overflow
See other posts from Stack Overflow
or by Rafael Oliveira
Published on 2010-03-19T18:57:36Z
Indexed on
2010/03/19
19:01 UTC
Read the original article
Hit count: 475
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 ?
© Stack Overflow or respective owner