[英]How to use Navigation Controller inside of UITabBarController with Storyboard on Swift
I'm using swift.
我正在使用swift。 I would like to use Navigation inside of TabBar with Storyboard.
我想在TabBar中使用导航与故事板。 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.
但是当我移动到第二个显示器时,第二个显示器显示没有标签菜单。
I selected segue type "show (egPush)" 我选择了segue类型“show(egPush)”
How can I keep displaying tab menu on all views? 如何在所有视图上继续显示标签菜单?
In Interface Builder: 在Interface Builder中:
UITabBarController
and set it as the initial View Controller. UITabBarController
并将其设置为初始视图控制器。 UITableViewController
. UITableViewController
。 UITableViewController
and go to the menu bar > Editor > Embed in > Navigation Controller
. UITableViewController
并转到menu bar > Editor > Embed in > Navigation Controller
。 UITabBarController
and CTRL-drag from it to the UINavigationController
. UITabBarController
并按CTRL拖动它到UINavigationController
。 Relationship Segue > view controllers
. Relationship Segue > view controllers
。 UINavigationController
stack will be presented in the same UITabBarController
. UINavigationController
堆栈中添加的任何View Controller将显示在同一个UITabBarController
。 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: 要从连接到
UINavigationController
的第一个堆栈UITableViewController
执行segue到另一个ViewController,您当然必须首先创建另一个ViewController,在Interface Builder
中创建一个segue,为您的segue创建一个标识符并在您的代码中执行它通过调用Swift中的相应函数,如:
optional func performSegueWithIdentifier(_ identifier: String,
sender sender: AnyObject?)
Here's a sample on how your Interface Builder could look like: 以下是Interface Builder的外观示例:
Here's a rough overview on how your Storyboard will look like. 以下是故事板的外观概述。 You have to use Tab Bar Controller as a rootViewController.
您必须使用Tab Bar Controller作为rootViewController。
Embed UITableViewController
to a UINavigationController
, so that you always have a back button. 将
UITableViewController
嵌入到UINavigationController
,以便始终有一个后退按钮。
There are endless possibilities for improvement as long as you follow Combined View Controller Interfaces . 只要您遵循组合视图控制器接口,就有无限的改进可能性。 Here's what a demo will look like with a common tab as you wanted -
以下是您想要的常见选项卡的演示内容 -
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.