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

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

问题描述

使用 XCode,并通过代码或故事板,有人可以向我解释如何将标签栏和导航栏添加到我的视图控制器中,同时保持两者可见吗?

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?

非常感谢.

推荐答案

在 Storyboard 中,您应该拖出一个 Tab Bar Controller 并将其用作初始视图控制器.然后,您应该将附加到标签栏控制器的每个视图控制器嵌入到导航控制器中(编辑器菜单:嵌入 > 导航控制器).之后,您的故事板应如下所示:

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-如何将标签栏和导航栏添加到单个视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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