覆盖标签栏的视图

我有一个UIViewController内部的标签栏。 对于Tab栏中的一个VC,我允许界面在设备旋转时旋转。 挑战是,我想隐藏标签栏并调整我的视图里面。

我做了什么:

1)在我的标签栏控制器中调用- (void)willAnimateRotation....并将self.tabBar.isHidden设置为true – > Tab栏消失。

2)调用- (void)willAnimateRotation....并将self.mapView.frame设置为最大高度。

但是…我仍然有一个黑色的条纹在屏幕的底部的标签栏的确切大小。 有没有办法如何使标签栏完全消失?

 [self hideTabBar:self.tabBarController]; - (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)viewDidLoad { [super viewDidLoad]; previousRect = self.view.frame; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; { if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { [self.navigationController setNavigationBarHidden:TRUE animated:FALSE]; [[UIApplication sharedApplication] setStatusBarHidden:TRUE animated:FALSE]; } else { [self.navigationController setNavigationBarHidden:FALSE animated:FALSE]; [[UIApplication sharedApplication] setStatusBarHidden:FALSE animated:FALSE]; } } -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { UIInterfaceOrientation toOrientation = self.interfaceOrientation; if ( self.tabBarController.view.subviews.count >= 2 ) { UIView *transView = [self.tabBarController.view.subviews objectAtIndex:0]; UIView *tabBar = [self.tabBarController.view.subviews objectAtIndex:1]; if(toOrientation == UIInterfaceOrientationLandscapeLeft || toOrientation == UIInterfaceOrientationLandscapeRight) { transView.frame = CGRectMake(0, 0, 480, 320 ); tabBar.hidden = TRUE; } else { transView.frame = previousRect; tabBar.hidden = FALSE; } } } 

如果你想在一个特定的UIViewController被推送时总是隐藏标签栏,你可以这样做:

 self.hidesBottomBarWhenPushed = YES;