Search code examples
iosuinavigationcontrolleruitabbarcontrolleruistoryboarduitabbar

How to preserve TabBar interface when the previous view was from a Navigation Controller


Here the basic navigation scheme in my application

https://i.sstatic.net/xaDtw.jpg

Once I access the first view of the Tabbed View Controller, the TabView button interface is not present, rather only the top navbar with a "back" button. I want the View governed by both controllers. I've seen a lot of posts around here about this but they're all severely outdated and any pages linked to are no longer available.


Solution

  • You need to change this:

          NavController-->tabBarController
                                   |
                                   |
                                   |->Item1ViewController
                                   |
                                   |->Item2ViewController
                                   |
                                   |->Item3ViewController
    

    To this:

                          tabBarController
                                   |
                                   |
                                   |-->NavController->Item1ViewController
                                   |
                                   |-->NavController->Item2ViewController
                                   |
                                   |-->NavController->Item3ViewController
    

    How you manage this part:

    -->NavController-->ViewController-->TabBarController
    

    Depends on what you are aiming to do... is that viewController a loginScreen for example? You have various options such as

    -->NavController-->ViewController--[modal segue]-->TabBarController
    
    -->TabBarController-->Item1ViewController--[modal segue]-->loginController
    

    That's a broader app design issue...

    I have related answers here: My Tab bar controller disappears after a push segue

    and here: How to handle UINavigationControllers and UITabBarControllers iOS 6.1