1

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

我做了什么:

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

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

但是...我在屏幕底部仍然有一个与标签栏大小完全相同的黑色条纹。有没有办法让标签栏完全消失?

4

3 回答 3

1

如果您想在推送特定UIViewController内容时始终隐藏标签栏,您可以执行以下操作:

self.hidesBottomBarWhenPushed = YES;
于 2014-03-20T11:49:52.283 回答
1

这对我有用

- (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;
        }
    }
}
于 2012-09-11T13:37:38.207 回答
1
[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];    
}
于 2012-09-11T13:30:27.610 回答