如何从超级视图中删除标签栏控制器?

时间:2012-01-28 17:52:06

标签: objective-c ios uitabbarcontroller

我添加了一个标签栏控制器,它以编程方式有5个项目,然后我想从每个项目返回到superview。我怎样才能做到这一点? removefromSuperView?

1 个答案:

答案 0 :(得分:0)

- (void) hidetabbar:(BOOL)hiddenTabBar 
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    for(UIView *view in self.uiTabBarController.view.subviews){
        if([view isKindOfClass:[UITabBar class]]) {
            if (hiddenTabBar) {
                [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
            }
        } else {
            if (hiddenTabBar) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
            }
        }
    }
    [UIView commitAnimations];  
}

It would be preferable to visit要有更好的主意。