Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation controller with tab bar controller?

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!!

like image 910
winston Avatar asked Jul 06 '16 02:07

winston


People also ask

What is a tab bar controller?

A tab bar controller is a powerful UI component for iOS apps. It's a container view, and you use it to group view controllers together. They give your app's user access to the most important screens of your app.

How do I add a controller to my tab bar controller storyboard?

Open Main. storyboard and select the map view controller. From Xcode's Editor menu, choose Embed In → Tab Bar Controller. This will add the map view controller to the view controllers array of a new tab bar controller.

What is a navigation controller?

NavController manages app navigation within a NavHost . Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly. Navigation flows and destinations are determined by the navigation graph owned by the controller.


1 Answers

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
}
like image 166
Lech H. Conde Avatar answered Nov 15 '22 04:11

Lech H. Conde