首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >隐藏并添加UITabbarController

隐藏并添加UITabbarController
EN

Stack Overflow用户
提问于 2014-01-02 08:23:35
回答 2查看 88关注 0票数 0

我是ios开发公司的新手。我有个问题。

现在,在我的项目中,我使用了带有2 viewControllers的viewControllers(ViewController1,ViewController2)。

ViewController1是起始页。当我运行每一页时(ViewController1,ViewController2,ViewController3,.)有UITabBarController。

但是在某些页面(例如: ViewController4)中,我想隐藏并在ViewController4中添加新的UITabBarController2

  • 如果我在ViewController4中使用“ViewController4”命令“UITabBarController”,则不会出现UITabBarController。
  • 如果我没有在ViewController4中使用“ViewController4”命令“UITabBarController1”,则会出现UITabBarController1和UITabBarController2 (两者都会出现)。

如何修理?

感谢你的帮助,为我在英语方面的错误感到抱歉。^^

EN

回答 2

Stack Overflow用户

发布于 2014-01-03 08:11:50

试着用这个隐藏选项卡

代码语言:javascript
复制
 - (void)hideTabBar:(UITabBarController *) tabbarcontroller
 {
       CGRect screenRect = [[UIScreen mainScreen] bounds];

       [UIView beginAnimations:nil context:NULL];
       [UIView setAnimationDuration:0.5];
       float fHeight = screenRect.size.height;
       if(  UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) ){
           fHeight = screenRect.size.width;
       }

       for(UIView *view in tabbarcontroller.view.subviews){
            if([view isKindOfClass:[UITabBar class]]){
                 [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
            }else{
                 [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
                 view.backgroundColor = [UIColor blackColor];
            }
       }
       [UIView commitAnimations];
 }

代码语言:javascript
复制
 [self hideTabBar: UITabBarController1];
票数 0
EN

Stack Overflow用户

发布于 2014-01-03 08:19:22

代码语言:javascript
复制
app.tabBarController.tabBar.hidden=TRUE;

app.tabBarController.tabBar.hidden=TRUE;

//Set some tab
[app.tabBarController setSelectedIndex:0];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20878960

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档