Hi all,
In my app have a navigation controller with 2 view controller : FirstViewController, SecondViewController. In the FirstViewController, I need show the navigation bar but hide it in SecondVieController. Since by default the navigation bar is not hidden, so I didn't set the navigationBarHidden status in FirstViewController and just let it displayed on the first view.
In the SecondViewController, since I need hide it so I set navigationBarHidden property in SecondViewController's viewWillAppear and ViewWillDisappear method as below:
SecondViewController.m
And it works fine, I can hide the navigation bar in SecondViewController. The SecondViewController consists a custom UIButton which used to pop out the SecondViewController and back to FirstViewController. So, what happened is when I click this button and back to FirstViewController, the navigation bar does not appear in FirstViewController.
Anyone know why this happened? The above [self.navigationController setNavigationBarHidden:NO animated:NO] in the viewWillDisappear does not take effect is because of the SecondViewController already popped out? Am I right?
Any suggestions and comments are welcome. Thanks a lot.
In my app have a navigation controller with 2 view controller : FirstViewController, SecondViewController. In the FirstViewController, I need show the navigation bar but hide it in SecondVieController. Since by default the navigation bar is not hidden, so I didn't set the navigationBarHidden status in FirstViewController and just let it displayed on the first view.
In the SecondViewController, since I need hide it so I set navigationBarHidden property in SecondViewController's viewWillAppear and ViewWillDisappear method as below:
SecondViewController.m
Code:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:NO];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:NO];
[super viewWillDisappear:animated];
}
- (IBAction)backToFirstVC:(id)sender
{
[self.navigationController popViewControllerAnimated:NO];
}
And it works fine, I can hide the navigation bar in SecondViewController. The SecondViewController consists a custom UIButton which used to pop out the SecondViewController and back to FirstViewController. So, what happened is when I click this button and back to FirstViewController, the navigation bar does not appear in FirstViewController.
Anyone know why this happened? The above [self.navigationController setNavigationBarHidden:NO animated:NO] in the viewWillDisappear does not take effect is because of the SecondViewController already popped out? Am I right?
Any suggestions and comments are welcome. Thanks a lot.