简体   繁体   English

如何在特定视图中隐藏标签栏?

[英]How to hide the tabbar in a particular view?

Im working on tab bar application. 我在标签栏应用程序上工作。

in all the view tabbar carried. 在所有视图tabbar中进行。 ok. 好。

but in a particular one view i didn't want to display my tabbar. 但在一个特定的视图中,我不想显示我的tabbar。

when i pushed my view to the next view, tab bar carried to that view also. 当我将视图推到下一个视图时,标签栏也会进入该视图。

when i tried to hide this it shows white space for that view. 当我试图隐藏它时,它显示该视图的空白区域。

what to do.. thnaks in advance 怎么办..提前thnaks

try.... 尝试....

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

UITabBar is a top level view which means that almost all over views are underneath it. UITabBar是一个顶级视图,这意味着几乎所有视图都位于其下方。 Even UINavigationController seats bellow tabBar. 甚至UINavigationController的座位也会低于tabBar。

You could hide tabBar like this: 你可以像这样隐藏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];
}

And then show it back on like this: 然后像这样展示回来:

- (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 is of height 50 px by default. UITabBar默认高度为50像素。 So you just need to set new height to the frame and animate it. 所以你只需要为框架设置新的高度并为其设置动画。

您可以将视图添加到主窗口,它将位于选项卡栏上:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM