4
votes

I have a tableViewController embedded in my tab bar controller. When a cell is tapped, a segue is launched to another view controller to show the details of that object. However, the Back button is not appearing in the viewDetail. I tried embedding the view into a separate Navigation Controller but that didn't change anything. What am I doing wrong? I currently have Tab Bar Controller -> tableView -> Navigation Controller -> viewDetail (need Back button here to return to tableView).

Here's what I have right now:

enter image description here

Thanks!!

3
no, you should do tabbar->navigation controller->tableview->detail view - Surely
You just have the organization wrong. Currently you have Tab Bar Controller -> tableView -> Navigation Controller -> viewDetail. It should be Tab Bar -> tableview. Tableview cell -> View detail. Navigation should be separate pointing to table view. Nothing should be pointing to navigation. It should just point to tableview - Ryan Tobin

3 Answers

18
votes

Each UIViewController in UITabBarController could be embedded in an UINavigationController at your convenience, that way you'll be able to use all of the features that you need.

Basically, you need to select the tableViewController, click on Editor menu item, select Embed in and click on Navigation Controller, ta daa.

UINavigationController Example

You can show or hide Navigation Bar if you need it using Interface Builder or programmatically in your Detail viewController as follows:

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.navigationBarHidden = true
    // Do stuff
}
4
votes

Set NavigationController to TabBarController, then set NavigationController's rootViewController to TableViewController.

enter image description here

2
votes

You just have the organization wrong. Currently you have Tab Bar Controller -> tableView -> Navigation Controller -> viewDetail. It should be Tab Bar -> tableview -> View detail. Navigation should be separate pointing to table view. Nothing should be pointing to navigation. It should just point to tableview

enter image description here

It should look something like the above picture