Currently the home page of my application hides the navigation bar; however, whenever I attempt to push that controller over to the next viewController it also hides that navigation bar too. I currently have this is the view controller WITHOUT a navigation bar:
[self.navigationController pushViewController: mapView animated:YES];
Whenever this pushes to the next one it does not have one anymore. The next viewController's navigation bar is in the viewWillAppear
method, so it should show up. Any ideas?
ANSWER:
If you hide your navigation bar in a ViewController and wish to show it in the next one then use the following code:
someVC *VC = [[someVC alloc] init];
self.navigationController.navigationBarHidden=NO;
[self.navigationController pushViewController: VC animated:YES];
@LithuT.V and @Tendulkar Thank you!
However, unlike iOS, when we Navigator.push to a new screen, this bottomNavigationBar disappears. In my app, I want to fulfil this requirement: Home screen has a bottomNavigationBar with 2 items ( a & b) presenting screen A & B.
By default, screen A is displayed. Inside screen A, there is a button. Tap that button, Navigator.push to screen C. Now in screen C, we can still see the bottomNavigationBar. Tap item b, I go to screen B. Now in screen B, tap item a in the bottomNavigationBar, I go back to screen C (not A, A is currently below C in the navigation hierarchy).
In iOS, we have a UITabBarController which stays permanently at the bottom of the screen when we push to a new ViewController. In iOS, we have a UITabBarController which stays permanently at the bottom of the screen when we push to a new ViewController.
Write this code in the ViewDidload method of mapView
[self.navigationController.navigationBar setHidden:NO];
I spent two hours trying to show my navigation bar on a view controller pushed from a different storyboard.
Note that only one navigation controller is needed in main storyboard, then for your view controller where the navigation bar disappears hide it and show it again by the following code.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
I guess your are hiding your navbar from storyboard, try the below code:
//Show navigationBar for a particular VC
-(void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO];
}
-(void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES];
}
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