Reputation: 61
I have a root vc embed in the navigation vc, I set the navigation bar hidden using
[self.navigationController setNavigationBarHidden:YES];
It works fine, the navigation bar disappears.
And push the 2nd vc use
[self.navigationController pushViewController:controller animated:YES];
In the 2nd vc set the navigation bar display. Everything goes well.
So when I clicked the 'back button' on the navigation bar, I found the navigation bar disappeared faster than the view, especially set the view's background to black, I can see
the whole view is black just like there're not any navigation bar ever.
I don't want this, I just hope the navigation bar will always present until the viewDidDisappear.
Here is a picture of the problem
I use [self.navigationController popViewControllerAnimated:YES];
and must fill the Animated is YES can reproduce this appearance.
For the sort,
[self.navigationController popViewControllerAnimated:YES]
to back. Where is the code location:
ps:whatever how you set the navigation bar's hidden-property, in ViewDidLoad or ViewWillAppear or ViewDidAppear or other place, they are all the same appearance.
in the root vc's viewDidLoad
[self.navigationController setNavigationBarHidden:YES];
and root vc's didSelectRowAtIndexPath:
[self.navigationController setNavigationBarHidden:NO];
Upvotes: 1
Views: 1479
Reputation: 17530
You just need to move the call of setNavigationBarHidden:Yes
from 2nd vc's viewWillDisappear:
to root vc's viewDidAppear:
.
I know visually this is not pleasant. I just gave you what you said you wanted: "I just hope the navigation bar will always present until the viewDidDisappear." For a nice transition you need to use custom transition.
Upvotes: 1
Reputation: 61
Upvotes: 2
Reputation: 995
You should move [self.navigationController setNavigationBarHidden:NO];
to your subVC's viewWillAppear:
and move [self.navigationController setNavigationBarHidden:YES];
to your RootView's viewWillAppear:
Upvotes: 0
Reputation: 2225
Frome ViewDidLoad, move [self.navigationController setNavigationBarHidden:YES]; in ViewDidAppear method. It will work.
Upvotes: 0