Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide uitabbarcontroller

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.

like image 889
Viktor Apoyan Avatar asked Mar 11 '11 11:03

Viktor Apoyan


People also ask

How do I hide the tab bar?

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.

How do I hide the tab bar in IOS?

Simply, Go to ViewController (in StoryBoard) -> Attribute inspector -> Under 'View Controller' section select 'Hide Bottom Bar on Push' checkbox. This works like a charm.

How do you hide the tab bar when a view controller is shown?

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.

How do I hide the bottom bar in Swift?

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.


1 Answers

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];  } 
like image 64
Saurabh Avatar answered Oct 02 '22 17:10

Saurabh