The view controller setup looks like this:
UITabBarController
- Tab 1
- UINavigationController
- UITableViewController
- select row pushes UIViewController (self.navigationController pushViewController)
- select button pushes another UIViewController
- Tab 2
- UIViewcontroller
My AppDelegate
should reflect the setup above and looks like this:
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
UITabBarController* tabBarController = [[UITabBarController alloc] init];
UITableViewController* myListController = [[MyListController alloc] init];
myListController.hidesBottomBarWhenPushed = YES;
UINavigationController* navigationControllerMyList = [[UINavigationController alloc] initWithRootViewController:myListController];
navigationControllerMyList.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
UIViewController* simpleViewController = [[SimpleViewController alloc] init];
simpleViewController.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:0];
tabBarController.viewControllers = @[ navigationControllerMyList , simpleViewController ];
self.window = [[UIWindow alloc] init];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
The problem I face is that once I select a row in the table view controller the tab bar hides as expected by setting myListController.hidesBottomBarWhenPushed = YES;
On UINavigationController
navigate back the tabbar doesn't show up again but I would expect to show it again. But only if I'm at the root of the navigation controller.
I tried to set tabBar.hidden
to NO
in the UITableViewController
but once I navigated back and for the tabBar is always visible.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.tabBarController.tabBar.hidden = NO;
}
I saw also this answer which basically says I've to manage the tabbar in every view controller myself. I try to avoid this.
What do I miss to correctly hide and show the tabbar only at the navigation controller root?