I have this problem: i have a view controller (embedded in a navigation controller) that after doing an action triggers a manual segue pushing a new view controller, however in the new view controller there is no navigation bar because in the first controller i had implemented the viewWillDisappear method like this:
- (void)viewWillDisappear:(BOOL)animated {
// Hide the navigation bar just before the view disappear
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
Here is the code for the manual segue that's inside an IBAction:
[self performSegueWithIdentifier:@"tutorialSegue" sender:self];
I'd tried like this
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[[self navigationController] setNavigationBarHidden:NO animated:NO];
}
but it doesn't work, actually in the debugger i noticed navigationcontroller is equal to nil and i just can't figured out why.
If you want StartViewController to hide navigation bar, and DestinationViewController to show it:
Add corresponding code to -(void)viewWillAppear:
method.
StartViewController:
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
DestinationViewController:
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
If you want both view controllers to have navigation bar, just remove all lines that contain setNavigationBarHidden: