Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alternating between toolbar / tab bar

my app is structured as follow: UITabBarController > UINavigationController > ViewControllerOne > ViewControllerTwo. the UINavigationBar has at the bottom the tab bar, now when the user navigates into the second view controller, i want to be able to hide the tab bar and replace is with a tool bar. i tried this code:

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

when i run the app the tab bar is hidden but the toolbar doesn't appear. plus, since the last VC is a table view controller, when i scroll through the cells there is a white gap between the table and the bottom of the view. how can i fix that?

like image 354
HusseinB Avatar asked Nov 28 '13 12:11

HusseinB


1 Answers

That won't work because when you hide the tab bar like that the subviews won't be adjusted properly (that's why you get the white space). You'll have to use

self.hidesBottomBarWhenPushed = YES;

In your init method or awakeFromNib... and then

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

In the viewDidLoad for example.

That way the tab bar controller's view is going to layout correctly it's subviews when you hide the tab bar. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller otherwise the tab bar is still going to be hidden when the second view controller is popped from the navigation stack.

like image 169
Ivan Genchev Avatar answered Sep 21 '22 16:09

Ivan Genchev