Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone tabbar的隐藏和取消隐藏_Iphone_Tabbar - Fatal编程技术网

Iphone tabbar的隐藏和取消隐藏

Iphone tabbar的隐藏和取消隐藏,iphone,tabbar,Iphone,Tabbar,我有一个tabbar控制器。我想在一个视图中隐藏选项卡栏,并想在下一个视图中取消隐藏同一选项卡栏。隐藏代码对第一个视图有效,但在第二个视图中,我取消隐藏选项卡栏的代码无效 我的代码: 对于隐藏: [[self navigationController] setHidesBottomBarWhenPushed:YES]; 要取消隐藏,请执行以下操作: [[self navigationController] setHidesBottomBarWhenPushed:NO]; h m 请停止在这么

我有一个tabbar控制器。我想在一个视图中隐藏选项卡栏,并想在下一个视图中取消隐藏同一选项卡栏。隐藏代码对第一个视图有效,但在第二个视图中,我取消隐藏选项卡栏的代码无效

我的代码:

对于隐藏:

[[self navigationController] setHidesBottomBarWhenPushed:YES];
要取消隐藏,请执行以下操作:

[[self navigationController] setHidesBottomBarWhenPushed:NO];
h

m


请停止在这么多答案上不带上下文地转储相同的代码。@Tim Post我花了大约3个小时来实现这一点。因此,我将这些代码全部共享,并为他们提供关于我的答案的通知。好的,我不再重复了。我忘了刚刚传递链接。对不起,我不会再犯这个错误。您可以传递链接评论,那就太好了。还请为这个答案添加一些上下文,现在它只是一个代码转储,可能会让人们忽视它的有用性。@tim ok buddy。事实上,我是作为评论给他们的。在下一篇文章中,我会尽我所能做到最好。谢谢勾选以下链接。它可以帮助您显示和隐藏选项卡栏。
 - (void) hideTabBarOfThisTabbarController:(UITabBarController *) tabbarcontroller withAnimationDuration:(int)duration;

 - (void) showTabBarOfThisTabbarController:(UITabBarController *) tabbarcontroller withAnimationDuration:(int)duration;
- (void) hideTabBarOfThisTabbarController:(UITabBarController *) tabbarcontroller withAnimationDuration:(int)duration{

    [UIView transitionWithView:tabbarcontroller.tabBar duration:duration options: UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction animations:^(void) {

        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)];
            }

        }


    } completion:^(BOOL finished) {


        NSLog(@"tabbar hidden");

    }];


}

- (void) showTabBarOfThisTabbarController:(UITabBarController *) tabbarcontroller withAnimationDuration:(int)duration{


    [UIView transitionWithView:tabbarcontroller.tabBar duration:duration options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction animations:^(void) {



        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)];
            }


        }


    } completion:^(BOOL finished) {


        NSLog(@"tabbar shown");

    }];


    //u can call like this

    //[self hideTabBarOfThisTabbarController:self.tabBarCon withAnimationDuration:3];

    //if u want immediately hide/show the tabbar then duration should be 0.0