i am using this in my view didlod [self.navigationController开发者_如何学Go setNavigationBarHidden:YES]; it hides when applicationn launches but when i navigate to next screen and come back to main view is not hide it navigation bar... why is it like that?
should i add any thing ?
....
This works for me:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
You wouldn't then need the one in viewDidLoad.
If it's not clear from that change, the reason your original code didn't work is that the view may be kept in memory even if it is not on screen - so need to hide / display the navigation bar each time the view is brought on or off screen.
viewDidLoad only fires the first time it loads your view. viewWillAppear fires every time.
精彩评论