如何在Swift上使用故事板的UITabBarController内部使用导航控制器 [英] How to use Navigation Controller inside of UITabBarController with Storyboard on Swift
问题描述
我正在使用swift。
我想在TabBar中使用导航与故事板。
首先,第一个显示在选项卡菜单中显示。
但是当我移动到第二个显示器时,第二个显示器显示没有标签菜单。
I'm using swift. I would like to use Navigation inside of TabBar with Storyboard. At first, the first display show up inside of tab menu. But when I move to second display, second display show up without tab menu.
我选择了segue类型show(egPush)
I selected segue type "show (e.g.Push)"
如何在所有视图上继续显示标签菜单?
How can I keep displaying tab menu on all views?
推荐答案
在Interface Builder中:
In Interface Builder:
- 创建
UITabBarController
并将其设置为初始视图控制器。 - 创建
UITableViewController
。 - 选择
UITableViewController
并转到菜单栏>编辑>嵌入>导航控制器
。 - 选择
UITabBarController
并按CTRL拖动到UINavigationController
。 - 选择
关系Segue>查看控制器
。 - 现在,您将在
UINavigationController
堆栈中添加的任何视图控制器将显示在相同的UITabBarController
。
- Create an
UITabBarController
and set it as the initial View Controller. - Create an
UITableViewController
. - Select the
UITableViewController
and go to themenu bar > Editor > Embed in > Navigation Controller
. - Select your
UITabBarController
and CTRL-drag from it to theUINavigationController
. - Choose
Relationship Segue > view controllers
. - Now, any View Controller you will add in the
UINavigationController
stack will be presented in the sameUITabBarController
.
从第一个执行segue stack UITableViewController
连接到 UINavigationController
,到另一个ViewController你必须首先创建另一个ViewController,为它创建一个segue在 Interface Builder
中,为您的segue创建一个标识符,并在您的代码中通过调用Swift中的相应函数来执行它,如:
To perform a segue from the first-in-stack UITableViewController
connected to the UINavigationController
, to another ViewController you must of course first create another ViewController, create a segue to it in Interface Builder
, create an identifier for your segue and in your code perform it by calling the appropriate function in Swift like:
optional func performSegueWithIdentifier(_ identifier: String,
sender sender: AnyObject?)
以下是关于Interface Builder的样子的示例:
Here's a sample on how your Interface Builder could look like:
这篇关于如何在Swift上使用故事板的UITabBarController内部使用导航控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!