I have a problem with UITabBarController
. In my application, I want to hide it but without using hidesBottomBarWhenPushed
because I want to hide it not when I pushed it. For Example, I want to hide it when I press a Hide button in my application.
I read many articles in google but I cant find out how I can do this.
If using Storyboards you can simply uncheck a checkbox in your ViewController's Attribute Inspector. It's called "Hide Bottom Bar on Push". Very convenient indeed, and no need to handle the showing of the tabBar again after navigating back from your tabBar-less viewController.
Simply, Go to ViewController (in StoryBoard) -> Attribute inspector -> Under 'View Controller' section select 'Hide Bottom Bar on Push' checkbox. This works like a charm.
If you don't want that behavior, you should set hidesBottomBarWhenPushed to true where applicable. This will hide the tab bar along with any toolbars you had showing, but only when a view controller is pushed onto the navigation stack. This allows you to show the tab bar at first, then hide it when you need more room.
Answer: Use self. tabBarController?. tabBar. hidden instead of hidesBottomBarWhenPushed in each view controller to manage whether the view controller should show a tab bar or not.
I am pasting this from my working code... you can call these methods to hide and show the tabbarcontroller.... just pass tabbarcontroller instance to these functions..
// Method call [self hideTabBar:self.tabBarController];
// Method implementations - (void)hideTabBar:(UITabBarController *) tabbarcontroller { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; for(UIView *view in tabbarcontroller.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)]; } } [UIView commitAnimations]; } - (void)showTabBar:(UITabBarController *) tabbarcontroller { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; for(UIView *view in tabbarcontroller.view.subviews) { NSLog(@"%@", view); if([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)]; } } [UIView commitAnimations]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With