Alternating between toolbar / tab bar

my application is structured as follows: UITabBarController> UINavigationController> ViewControllerOne> ViewControllerTwo. The UINavigationBar is at the bottom of the tab bar, now that the user goes to the second view controller, I want me to be able to hide the tab bar and replace it with the tool bar. I tried this code:

[self.navigationController.tabBarController.tabBar setHidden:YES]; [self.navigationController.toolbar setHidden:NO]; 

when i run the application the tab bar is hidden but the toolbar is not showing. plus, since the last VC is the table view controller, when I browse the cells, there is a white gap between the table and the bottom of the view. how can i fix this?

+7
ios uitoolbar uitabbar
source share
2 answers

This will not work, because when you hide the tab bar, the moving objects will not be correctly configured (this means that you are getting empty space). You will need to use

 self.hidesBottomBarWhenPushed = YES; 

In your init or awakeFromNib method ... and then

 [self.navigationController setToolbarHidden:NO animated:YES]; 

In view viewDidLoad.

Thus, the tab bar controller view will be correctly placed, it will be displayed when the tab bar is hidden. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller, otherwise the tab bar will still be hidden when the second display controller is popped out of the navigation stack.

+10
source share

Try to assign the toolbar to the appropriate frame and add it to self.tabBarController.view

0
source share

All Articles