1
votes

My storyboard is as below:

enter image description here

UINavigationController 
    |
 UITabbarController
      |
    HomeVC - Container
                 |
               PageViewController
                    |
                  MainVC | MenVC | WomenVC | ElectronicsVC ...

I try to push a new view controller from MainVC, using tabbarcontroller. I want the bottom tabbar to be visible but I can't. Everytime when new viewcontroller is pushed, it will be in full screen.

In my NavigationHelper.m,

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainV3" bundle:nil];
    MyNewViewController *myNewVC = [storyboard instantiateViewControllerWithIdentifier:@"MyNewViewController"];
    [myTabbarController setHidesBottomBarWhenPushed:NO];
    [myTabbarController.navigationController pushViewController:myNewVC animated:YES];

    // I have checked myTabbarController and myNewVC instances are not nil.

The reason why I use pageviewcontroller in this design because I need few view controllers in first item of tabbarcontroller.

Set tabbarcontroller setHidesBottomBarWhenPushed property to YES before I push new controller is not working too.

I have checked the container inside HomeVC is not covering the tabbar.

2

2 Answers

2
votes

you need to set your TabBarController as root of the app, like in this scheme:

TabBarController -> Tab1 -> UINavigationController -> ViewContoller1 -> ViewContoller2.

ant not like:

NavigationController -> TabBarController -> VC1 -> VC2

In such case you can navigate between ViewContoller1 and ViewContoller2 and TabBarContoller will remain visible.

1
votes

This happens because when you invoke push on myTabbarController.navigationController, you actually add one more controller on the same hierarchy level as your UITabBarController controller.

UINavigationController 
      |
  UITabBarController  –> YourPushedViewController

Which obviously hides entire UITabBarController along with its bar and everything it contains.

If you want to have navigation inside particular tab — you should place UINavigationController inside this tab, and then do push using it.

So your new hierarchy should be something like this.

UITabBarController
    |
   FirstTab — SecondTab — ...
    |
   UINavigationController
    |
   HomeVC - Container
              |
           PageViewController
                |
              MainVC | MenVC | WomenVC | ElectronicsVC ...