简体   繁体   English

如何在Swift上使用故事板的UITabBarController内部使用导航控制器

[英]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中:

  1. Create an UITabBarController and set it as the initial View Controller. 创建一个UITabBarController并将其设置为初始视图控制器。
  2. Create an UITableViewController . 创建一个UITableViewController
  3. Select the UITableViewController and go to the menu bar > Editor > Embed in > Navigation Controller . 选择UITableViewController并转到menu bar > Editor > Embed in > Navigation Controller
  4. Select your UITabBarController and CTRL-drag from it to the UINavigationController . 选择你的UITabBarController并按CTRL拖动它到UINavigationController
  5. Choose Relationship Segue > view controllers . 选择Relationship Segue > view controllers
  6. Now, any View Controller you will add in the 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.

相关问题 如何在情节提要中访问正确的导航控制器 - How to acces the right navigation controller inside storyboard StoryBoard-UITabBarController + UINavigationController-从一个导航控制器跳转到另一个导航控制器 - StoryBoard - UITabBarController + UINavigationController - Jumping from one navigation controller to the other one 故事板-如何在UINavigationController中使用UITabbarController自定义UITabbarItem - Storyboard - How to custom UITabbarItem with UITabbarController inside UINavigationController 使用导航控制器在 Storyboard 中显示视图控制器 - Swift - Present View Controller in Storyboard with a Navigation Controller - Swift 如何直接从情节提要中的第一个导航控制器直接执行segue? - How to perform a segue directly from the first navigation controller in a storyboard in swift? 如何在导航控制器内的storyboard中从appdelegate推送viewcontroller - How to push viewcontroller from appdelegate in storyboard inside navigation controller 将故事板与自定义UITabbarController一起使用 - use storyboard with custom UITabbarController 使用Navigation Controller自定义segue到另一个故事板快速 - Custom segue with Navigation Controller to another storyboard swift Swift StoryBoard Reference segue到导航控制器而不是Root - Swift StoryBoard Reference segue to Navigation controller not Root 如何使用swift在故事板模式下重用UITabBarController中的视图控制器 - How to reuse view controllers in a UITabBarController in Storyboard mode with swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM