Hide navigation bar in storyboard

北战南征 提交于 2019-12-06 16:33:12

问题


Can anyone tell me how to hide the navigation bar in my storyboard. My code below is working fine when running in the simulator but it still appears in my storyboard which is really annoying me as it's messing around with the placement of my images. Can anyone help?

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

- (void) viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

回答1:


Click on the controller that has the top bar navigate to the properties bar on the right hand side of Xcode. There is a drop down labeled Top Bar (as shown above) change this drop down to none.




回答2:


You have to click the actual navigation controller, not the view controller. On the view controller the navigation drop down doesn't show up, but you can still achieve this by selecting Top Bar: none in Simulated Metrics.




回答3:


In the Storyboard view, just select the NavigationController scene and UNCHECK Shows Navigation Bar (Attributes Inspector)




回答4:


Solution for the same using Swift 3:

Step 1. Using attribute inspector hide Navigation Bar from Storyboard:

Step 2. Add the following code to your ViewController:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    // Hide the navigation bar on the this view controller
    self.navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    // Show the navigation bar on other view controllers
    self.navigationController?.setNavigationBarHidden(false, animated: animated)
}



回答5:


Follow these step:    
    1: Go to storyboard
    2: Select navigation controller
    3: Goto Attribute inspector
    4: Under navigation controller bar visibility **Uncheck the Shows navigation Bar***



来源:https://stackoverflow.com/questions/10620471/hide-navigation-bar-in-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!