简体   繁体   中英

How to use Navigation Controller inside of UITabBarController with Storyboard on Swift

在此输入图像描述 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.

I selected segue type "show (egPush)"

How can I keep displaying tab menu on all views?

In Interface Builder:

  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 .

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?)

Here's a sample on how your Interface Builder could look like: 在此输入图像描述

Here's a rough overview on how your Storyboard will look like. You have to use Tab Bar Controller as a rootViewController.

Embed UITableViewController to a UINavigationController , so that you always have a back button.

故事板设计

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 -

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM