21

enter image description hereI'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 (e.g.Push)"

How can I keep displaying tab menu on all views?

tajihiro
  • 2,293
  • 7
  • 39
  • 60
  • A better description (or screenshot) of your current storyboard setup would be helpful here. – Stuart Apr 05 '15 at 15:37
  • If you are using tab bar controller then simply editor->embed in->navigation controller. It will work as you are expecting. – Uttam Sinha Apr 05 '15 at 15:57
  • You can do it by maitaining view hierarcy as embedding your First TableViewController with the navigation controller and then again embedding your navigation controller with the tab bar controller. .Now just with some actions just push the second TableView Controller from the first one.... – LC 웃 Apr 05 '15 at 16:01
  • I don't know how to use stack overflow properly. Just I saw other's screenshot at first. It was easy for me whom it is difficult to understand English for. Thank you for your help anyway. – tajihiro Apr 05 '15 at 16:28

2 Answers2

35

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: enter image description here

Razvan
  • 4,122
  • 2
  • 26
  • 44
  • 1
    How do I style both navigation controllers to be the same in the Interface Builder? Can I style one and somehow copy that style to the other one? – h3dkandi May 10 '16 at 08:30
  • Is it possible to do the same thing, but instead of a table view, have another tabbar controller?? I have tried to achieve this, but my 2nd tabbar controller doesn't show any tabs... all I see is the tab from my 1st controller – jonahpup Jan 09 '19 at 21:07
9

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.

Storyboard design

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 -

enter image description here

raurora
  • 3,623
  • 1
  • 22
  • 29