0
votes

I have a tab bar controller with 4 tabs and each tab is their own UINavigationController, which is how you're supposed to nest tab bar and navigation controller's together. The initial tab is a TableViewController and works/appears the way that it should. From the tableVC I can push standard view controller's onto the navigation controller with:

[self.navigationController pushViewController:VC animated:YES];

and it works properly.

If I attempt to push another TableViewController onto the navigation with the same method it works the same way, but the initial tab bar does not get pushed off screen like it should, it just stays in place.

Why would the tab bar stay on screen even though I am pushing a new VC onto the navigation?

I have tested with multiple instances of different TableVC's and it only happens with a table view controller.

Here is the code I'm using:

- (void)pushTableVC
{
    TestTableVC *tableVC = [[TestTableVC alloc] init];

    [self.navigationController pushViewController:tableVC animated:YES];
}

This will push the new table view onto the stack, but the tab bar from the parent VC stays in place and does not get pushed off screen like it should.

2

2 Answers

1
votes

You should call the method setHidesBottomBarWhenPushed: on the view controller you are pushing to correctly hide the tab bar.

UIViewController *viewController = [[UIViewController alloc] init];

[viewController setHidesBottomBarWhenPushed:YES];

[[self navigationController] pushViewController:viewController animated:YES];
0
votes

When you use a UITabBarController, the tab bar always stays on screen, even as you push additional view controllers onto an embedded UINavigationController. You will see this in any app that has a UITabBarController implemented, unless they implement custom behavior to change this.

The UINavigationController contains everything above the UITabBar, but does not contain the UITabBar itself, so it would not be able to push it offscreen.