[英]Swift-How do I add Tab Bar AND Navigation Bar to a single view controller?
Using XCode, and either through Code or through the Storyboard, can someone please explain to me how to add both a Tab Bar and Nav Bar to my view controller while keeping both visible? 使用XCode,通过代码或通过故事板,有人可以向我解释如何将Tab Bar和Nav Bar添加到我的视图控制器同时保持可见?
Thanks so much. 非常感谢。
In your Storyboard, you should drag out a Tab Bar Controller and use that as the initial view controller. 在Storyboard中,您应该拖出一个Tab Bar Controller并将其用作初始视图控制器。 Then, you should embed each of the view controllers attached to the Tab Bar Controller inside Navigation Controllers (Editor menu: Embed In > Navigation Controller). 然后,您应该将附加到选项卡栏控制器的每个视图控制器嵌入到导航控制器(编辑器菜单:嵌入>导航控制器)中。 Afterward, your Storyboard should look something like this: 之后,你的Storyboard应该是这样的:
The tab bar controller holds a tab bar and will manage switching between the other views attached to it, while the navigation controllers will place Navigation Bars at the top of each tab and help you manage navigation within the tab. 标签栏控制器包含一个标签栏,并将管理与其连接的其他视图之间的切换,而导航控制器将导航栏放置在每个标签的顶部,并帮助您管理标签内的导航。
I am assuming you want something like this. 我假设你想要这样的东西。 Here is how I did it in Interface Builder: 以下是我在Interface Builder中的做法:
Editor -> Embed In -> Navigation Controller
Editor -> Embed In -> Tab Bar Controller
Is Initial View Controller
选中Is Initial View Controller
旁边的框 Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.