【问题标题】:How to hide the tabbar in a particular view?如何在特定视图中隐藏标签栏?
【发布时间】:2012-03-25 19:15:22
【问题描述】:

我正在开发标签栏应用程序。

在所有的视图标签栏中进行。好的。

但在一个特定的视图中我不想显示我的标签栏。

当我将视图推到下一个视图时,标签栏也被带到该视图。

当我试图隐藏它时,它会显示该视图的空白。

该做什么..提前考虑

【问题讨论】:

标签: iphone objective-c uitabbarcontroller uitabbar tabbar


【解决方案1】:

试试....

MyViewController *myController = [[MyViewController alloc] init];
//hide tabbar
myController.hidesBottomBarWhenPushed = YES;
//add it to stack.
[[self navigationController] pushViewController:myController animated:YES];

【讨论】:

    【解决方案2】:

    UITabBar 是一个顶级视图,这意味着几乎所有的视图都在它的下方。甚至 UINavigationController 也位于 tabBar 下方。

    你可以像这样隐藏 tabBar:

    - (void)hideTabBar:(UITabBarController *)tabbarcontroller withInterval:(NSTimeInterval)delay {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:delay];
        for(UIView *view in tabbarcontroller.view.subviews)
        {
            if([view isKindOfClass:[UITabBar class]])
            {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+50, view.frame.size.width, view.frame.size.height)];
            } 
            else 
            {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+50)];
            }
        }
        [UIView commitAnimations];
    }
    

    然后像这样重新显示它:

    - (void)showTabBar:(UITabBarController *)tabbarcontroller withInterval:(NSTimeInterval)delay {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:delay];
        for(UIView *view in tabbarcontroller.view.subviews)
        {
            if([view isKindOfClass:[UITabBar class]])
            {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-50, view.frame.size.width, view.frame.size.height)];
            } 
            else 
            {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-50)];
            }
        }
        [UIView commitAnimations];
    }
    

    UITabBar 默认高度为 50 像素。因此,您只需为框架设置新高度并为其设置动画即可。

    【讨论】:

      【解决方案3】:

      您可以将视图添加到主窗口,它将位于标签栏上方:

      [[myApp appDelegate].window addSubview:myView]; 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-29
        • 1970-01-01
        • 2021-06-01
        • 2011-08-24
        • 2011-11-07
        • 2015-01-03
        • 1970-01-01
        • 2013-09-21
        相关资源
        最近更新 更多