如何在Swift上使用故事板的UITabBarController内部使用导航控制器 [英] How to use Navigation Controller inside of UITabBarController with Storyboard on Swift

查看:354
本文介绍了如何在Swift上使用故事板的UITabBarController内部使用导航控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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:


  1. 创建 UITabBarController 并将其设置为初始视图控制器。

  2. 创建 UITableViewController

  3. 选择 UITableViewController 并转到菜单栏>编辑>嵌入>导航控制器

  4. 选择 UITabBarController 并按CTRL拖动到 UINavigationController

  5. 选择关系Segue>查看控制器

  6. 现在,您将在 UINavigationController 堆栈中添加的任何视图控制器将显示在相同的 UITabBarController

  1. Create an UITabBarController and set it as the initial View Controller.
  2. Create an UITableViewController.
  3. Select the UITableViewController and go to the menu bar > Editor > Embed in > Navigation Controller.
  4. Select your UITabBarController and CTRL-drag from it to the UINavigationController.
  5. Choose Relationship Segue > view controllers.
  6. Now, any View Controller you will add in the UINavigationController stack will be presented in the same UITabBarController.

从第一个执行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屋!

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