简体   繁体   English

在Interface Builder中使用Storyboard隐藏导航栏

[英]Hide Navigation Bar in Interface Builder w/ Storyboards

I have a pretty basic storyboard based app, with a UINavigationController, a main view and a secondary view, both of which are in the navigation hierarchy. 我有一个非常基本的基于故事板的应用程序,带有UINavigationController,主视图和辅助视图,两者都在导航层次结构中。 I'm currently hiding the navigation bar on the main view by using setNavigationBarHidden: as appropriate in viewWillAppear and viewWillDisappear . 我目前正在使用setNavigationBarHidden:隐藏主视图上的导航栏setNavigationBarHidden:viewWillAppearviewWillDisappear适当。 It seems like there should be a way to do this in Interface Builder, rather than in code. 似乎应该有一种方法可以在Interface Builder中执行此操作,而不是在代码中执行此操作。 Essentially I'd like the options available in the Simulated Metrics options, but not simulated. 基本上我想要模拟指标选项中可用的选项,但不是模拟的。 Does that exist? 那存在吗?

In the scene for the UINavigationController itself, I suppose you could check the hidden button for the nav bar in the Attributes inspector, but that would make the nav bar hidden for all the view controllers in the navigation stack. 在UINavigationController本身的场景中,我想您可以在“属性”检查器中检查导航栏的隐藏按钮,但这会使导航栏中的所有视图控制器隐藏导航栏。 But that's not what you want. 但那不是你想要的。

To hide the nav bar for an individual view controller using IB, you would need to use a stand alone nav bar for each view controller (eg, drap and drop a Navigation Bar from the object library in IB). 要使用IB隐藏单个视图控制器的导航栏,您需要为每个视图控制器使用独立的导航栏(例如,从IB中的对象库中拖放导航栏)。 To use a stand alone nav bar in a navigation stack would be more work than programmatically hiding the nav bar. 在导航堆栈中使用独立的导航栏比以编程方式隐藏导航栏更有用。

Just uncheck the Attribute Inspector > Shows Navigation Bar in Attribute Inspector 只需取消选中Attribute Inspector > Shows Navigation BarAttribute Inspector

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM