Reputation: 3768
i am using this in my view didlod [self.navigationController 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 ?
....
Upvotes: 0
Views: 797
Reputation: 17601
viewDidLoad only fires the first time it loads your view. viewWillAppear fires every time.
Upvotes: 0
Reputation: 37505
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.
Upvotes: 4