Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use hidesBottomBarWhenPushed if i want to hide the tabbar for only one kind of controller?

Tags:

ios

uitabbar

I have gotten in trouble while using hidesBottomBarWhenPushed... I will push three controllers – A, B, and C – into navigationcontroller in order, and I would like to hide bottom tab bar when B is shown.(and A is one of the tabbar controllers)

Does any one have ideas?

like image 431
Sibin Lu Avatar asked Nov 28 '22 03:11

Sibin Lu


2 Answers

In view controller A (which is on the tabBar), when it comes time to present B (no tabBar wanted):

self.hidesBottomBarWhenPushed = YES; // hide the tabBar when pushing B
[self.navigationController pushViewController:viewController_B animated:YES];
self.hidesBottomBarWhenPushed = NO; // for when coming Back to A

In view controller B, when it comes time to present C (tabBar wanted again):

self.hidesBottomBarWhenPushed = NO; // show the tabbar when pushing C
[self.navigationController pushViewController:viewController_C animated:YES];
self.hidesBottomBarWhenPushed = YES; // for when coming Back to B
like image 144
Jeff Avatar answered Dec 19 '22 17:12

Jeff


Instead of setting it in viewDidLoad, I have found that sometimes this is too late. Set it in init or override hidesBottomBarWhenPushed to return YES for views with no bottom toolbar.

like image 37
Peter DeWeese Avatar answered Dec 19 '22 18:12

Peter DeWeese