在保持触摸的同时按下UITabBar

时间:2012-06-30 11:05:25

标签: iphone objective-c ios uitabbarcontroller

我需要在一个视图控制器上隐藏UITabBar。我试过了

vc.hideTabBarwhenpushed = TRUE

被推;这工作正常,但是当我在这个视图控制器上打开UITable时,在UITabBar所在的底部,在那个地方UITable没有触及。 我试着做了

[viewController setWantsFullScreenLayout:YES];

但它没有用。

2 个答案:

答案 0 :(得分:2)

使用此代码隐藏并显示您的tabBar

//隐藏标签栏

- (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)
    {
        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]; 
}

答案 1 :(得分:0)

您需要确保正确设置表格视图的弹簧和支柱:

springs and struts