backButton of NavigationController don't appear
I have already post this question but this time I post code. So I have a uiviewController, and in the viewDidLoad of this viewController I hide the backButton of the navigationController. After that, I push a new uiviewcontroller, and I set the backbutton to visible in the viewDidLoad, but the backbutton is still hidden...
Implementation of the first uiviewcontroller
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"page2page2page2page2page2";
self.navigationItem.hidesBackButton = TRUE;
}
-(IBAction)click
{
page3 *controller = [[page3 alloc] init];
[self.navigationController pushViewController:controller animated:YES];
[page3 release];
}
Implementation of the page 3
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"page3";
self.navigationItem.hidesBackButton = FALSE;
开发者_开发知识库
}
and the page3 has no backbutton, but the space is created for the button, because the tile "page 3" is on the right and not in the center... all this happen with the ios 4.2
thx
Neither of the above workarounds seemed to work for me. However when the third view was being displayed, i could see the button blink for a moment. So I suspected the problem (bug) has to do with the animation
When change animated to NO on the pushViewController the problem went away
- (IBAction)btnNext:(id)sender {
[[self navigationController] pushViewController:thirdViewController animated:NO];
}
My trick is setting setNavigationBarHidden to YES and immediately NO.
[self.navigationItem setHidesBackButton:NO animated:YES];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO];
So as this the backButton not be animated but it's really work and my manager have not notice it ;P
I get the same behaviour and I must say I find it quite strange. I can't say why it doesn't work but as a workaround you can do:
In page2:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.navigationItem setHidesBackButton:YES animated:YES];
}
And in page3:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.navigationItem setHidesBackButton:NO animated:YES];
}
And remove the calls to self.navigationItem.hidesBackButton = ...
in both controllers.
Well, I had the same problem running iOS 4.2. The back button would refuse to appear. Upon autoroating to landscape, it then appears. My solution was to do the following - This fixed the problem...or should we say its a workaround ;)
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.hidesBackButton = YES;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.navigationItem.hidesBackButton = NO;
}
精彩评论