Reputation: 35953
I have a navigation based app with 2 controllers: vA and vB.
vA is the navigation controller's root view controller and it is a full screen controller, so when this controller is being shown, the navigation bar is hidden.
Then I push vB using
[self.navigationController pushViewController:vB animated:YES];
On vB's viewDidLoad I have this:
self.navigationController.navigationBarHidden = NO;
// then I have navigation buttons defined here
The animation of vB entering the screen from the right happens this way:
when I pop vB out, this is what happens
this animation has no grace, is terrible, clunky and wrong.
What I want is this: the navigation slides in and out together with vB.
how do I do that?
thanks.
Upvotes: 0
Views: 345
Reputation: 3896
Try the following:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
}
// OR viewWillDisappear as mentioned by @RubberDuck
Instead of hiding navigation bar in viewDidLoad
, implement viewWillAppear
and viewDidDisappear
Upvotes: 1
Reputation: 104082
You need to use the animated version of the method you used in vcB's viewDidLoad:
[self.navigationController setNavigationBarHidden:NO animated:YES];
After edit: It seems to work fine in either viewDidLoad or viewWillAppear (but not viewDidAppear). It needs to be in viewWillDisappear for going back.
Upvotes: 2