2012-04-11 67 views
0

我正在设计一个应用程序,它有超过4个选项的tabbar,所以我想要做的就是隐藏tabbar当任何视图被推动,并再次显示视图时弹出,我试过hidesbottomwhenpushed但me.Please没有工作,帮助iphone + hide tabbar当任何视图推

+0

你可以pl。显示代码如何做到这一点? – Ilanchezhian 2012-04-11 12:38:30

+0

其实,我所做的是,我已经选择了tabbarcontrollers选项“隐藏底部时推”通过xib.Is那里我缺少的东西。 – Shantanu 2012-04-11 12:48:05

回答

1

使用此功能

- (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]; 

} 

当你的时候,你要显示的调用这个函数

[self hideTabBar:self. tabbarcontroller]; 

tabbarcontroller使用此功能

- (void) showTabBar:(UITabBarController *) tabbarcontroller { 

        [UIView beginAnimations:nil context:NULL]; 
        [UIView setAnimationDuration:0.5]; 
        for(UIView *view in tabbarcontroller.view.subviews) 
        { 
            NSLog(@"%@", view); 

            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]; 
} 
+0

非常有用!我有一个问题:他不能隐藏UITabBar视图而不是改变其框架? – 2012-04-11 12:55:37

+0

你是否在应用程序删除中使用标签栏? – Deepesh 2012-04-11 12:59:49

+0

请使用目前的模型视图控制器(简单的方法) – Deepesh 2012-04-11 13:01:00