I am wanting to hide the UINavigationBar that automatically loads with the Navigation project for the first view only and am wondering how I can make this work.
I have tries to do it like this
//RootViewController.m
#import "mydelegate.h" //-- this is where the view controller is initialized
//...
- (void)viewDidLoad
{
[super viewDidLoad];
navigationController *navController = [[navigationController alloc] init];
[navigationController setNavigationBarHidden:YES animated:animated];
}
//.....
However I am getting errors because I guess I am not calling navigationController across from the delegate file properly or this is just not possible to call it like you would a method from another class.
Any help would be greatly appreciated.
There are a couple things wrong here.
self.navigationController
. Your code snippet is creating a new UINavigationController; hiding that bar won't get you anything.viewDidLoad
, you should hide it in viewWillAppear:
. You can hide the navigation bar in viewDidLoad
, and the navigation bar will be hidden when the view is initially presented, but if you were to push another view that presented the navigation bar and hit the back button, the navigation bar would remain visible. Your viewWillAppear:
should look something like this:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
And the viewWillAppear:
methods in other view controllers you push on this navigation controller should show or hide the navigation bar appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With