Swift-如何将Tab Bar和导航栏添加到单个视图控制器? [英] Swift-How do I add Tab Bar AND Navigation Bar to a single view controller?

查看:786
本文介绍了Swift-如何将Tab Bar和导航栏添加到单个视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用XCode,通过Code或通过Storyboard,有人可以向我解释如何将Tab Bar和Nav Bar添加到我的视图控制器同时保持可见吗?

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?

非常感谢。

推荐答案

在你的故事板中,你应该拖出一个标签栏控制器并将其用作初始视图控制器。然后,您应该将附加到选项卡栏控制器的每个视图控制器嵌入到导航控制器(编辑器菜单:嵌入>导航控制器)中。之后,你的故事板应该是这样的:

In your Storyboard, you should drag out a Tab Bar Controller and use that as the initial view 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:

标签栏控制器有一个标签栏,可以管理连接到它的其他视图之间的切换,而导航控制器会将导航栏放在每个标签的顶部,可帮助您管理标签中的导航。

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.

这篇关于Swift-如何将Tab Bar和导航栏添加到单个视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆