I worked in almost the same case, actually used the code http://www.developers-life.com/hide-uitabbarcontrolleruitabbar-with-animation.html and made it better according to my needs, this could help others too .
I use UISplitViewController as the root view controller, and its detailed part is UITabBarController, I needed to hide the panel in portrait mode:
// In UITabBarController custom implementation add following method, // this method is all that will do the trick, just call this method // whenever tabbar needs to be hidden/shown - (void) hidetabbar:(NSNumber*)isHidden { UITabBarController *tabBarController=self; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; CGRect tabbarFrame=CGRectZero; for(UIView *theView in tabBarController.view.subviews) { //NSLog(@"%@", view); if([theView isKindOfClass:[UITabBar class]]) { tabbarFrame=theView.frame; if ([isHidden boolValue]) { tabbarFrame=CGRectMake(tabbarFrame.origin.x, tabBarController.view.frame.size.height, tabbarFrame.size.width, tabbarFrame.size.height); } else { tabbarFrame=CGRectMake(tabbarFrame.origin.x, tabBarController.view.frame.size.height - tabbarFrame.size.height, tabbarFrame.size.width, tabbarFrame.size.height); } theView.frame=tabbarFrame; break; } } for(UIView *theView in tabBarController.view.subviews) { if(![theView isKindOfClass:[UITabBar class]]) { CGRect theViewFrame=theView.frame; if ([isHidden boolValue]) { theViewFrame=CGRectMake(theViewFrame.origin.x, theViewFrame.origin.y, theViewFrame.size.width, theViewFrame.size.height + tabbarFrame.size.height); } else { theViewFrame=CGRectMake(theViewFrame.origin.x, theViewFrame.origin.y, theViewFrame.size.width, theViewFrame.size.height - tabbarFrame.size.height); } theView.frame=theViewFrame; } } [UIView commitAnimations]; }
I used the following code to call hidetabbar: method
//In my UISplitViewController custom implementation - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { @synchronized(self){ //change the self.splitDetailController to your UITabBarController object [self.splitDetailController performSelector:@selector(hidetabbar:) withObject:[NSNumber numberWithBool:UIInterfaceOrientationIsLandscape(interfaceOrientation)] afterDelay:0.5]; } return YES; }
I tested this code to work only in the simulator, let me know if it works on the device; -)
Abduliam Rehmanius Dec 21 '11 at 3:18 2011-12-21 03:18
source share