I have found many posts, but still no solution. I am trying to hide a NavigationBar on the initial UIViewController
, but i want to still show it on the second UIViewController
. Here is my storyboard:
When I turn off the Inferred Top Bar for my Main View Controller, it disappears in Storyboard, but it still shows when I run the app. When I do the same in to the NavigationBar in NavController, it disappears for all three (because they all inherit the no Nav Bar).
I want to show the NavBar in ScrollViewV View Controller, but have it hidden in MainViewController
.
All Controllers have the corresponding .h or .m files, but I am confused on how to do this programmatically. Let me know if you need to see anything else. Thank you much!
In your mainViewController, you can do following:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
You might want to show the Navigation bar when hiding this ViewController, for that do the following:
- (void)viewDidDisappear: (BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
}
如果你想在 Storyboard 中保留东西而不是编辑用户定义的属性并将navigationController.navigationBarHidden
设置为一个布尔值检查。
self.navigationController.navigationBarHidden = YES;
I noticed that you also need to add the following to the controller that you do want the navigation to appear.
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillAppear:animated];
Anyone wanting to know how to do this in Swift?
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.navigationController?.navigationBar.hidden = true
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.