如何隐藏某些页面的tabbar并使其再次可见?

时间:2010-04-21 12:33:59

标签: iphone objective-c uitabbarcontroller tabbarcontroller

我有一个应用程序,它使用一个标签栏控制器和一个导航控制器。但是对于某些页面,我想隐藏两个栏(标签和导航),之后它们将再次可见......我能够隐藏导航栏&也完成了制作。它出现在一些页面之后。  我可以隐藏标签栏 - (BOOL)hidesBottomBarWhenPushed {  返回TRUE; }

但问题是如何在某些页面之后再次显示它?

1 个答案:

答案 0 :(得分:6)

[[self navigationController] setNavigationBarHidden:UIDeviceOrientationIsLandscape(toInterfaceOrientation) animated:YES];

然后在子类UITabBarController

- (void) hideTabBar:(BOOL)hide animated:(BOOL)animated {

    if (tabBarHidden == hide) { return; }

    if (animated) {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:1.5];
    }

    for(UIView *view in self.view.subviews) {

        if([view isKindOfClass:[UITabBar class]]) {

            if (!hide) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-49, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+49, view.frame.size.width, view.frame.size.height)];
            }
        } else {
            if (!hide) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-49)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+49)];
            }

        }
    }

    if (animated) { [UIView commitAnimations]; }

    tabBarHidden = hide;

}