tabbar的隐藏和取消隐藏

发布于 2024-11-27 13:07:26 字数 311 浏览 1 评论 0原文

我有一个标签栏控制器。 想在视图中隐藏选项卡栏,并想在下一个视图中取消隐藏相同的选项卡栏。隐藏代码适用于第一个视图,但在我取消隐藏选项卡栏的第二个视图中,它不起作用。

我 代码:

用于隐藏:

[[self navigationController] setHidesBottomBarWhenPushed:YES];

用于取消隐藏:

[[self navigationController] setHidesBottomBarWhenPushed:NO];

I have a tabbar controller. I want to hide the tab bar in a view and want to unhide the same tabbar in the next view.The hidding code is working for the first view but in the second view where i am unhiding the tab bar it is not working..

My code:

For Hiding:

[[self navigationController] setHidesBottomBarWhenPushed:YES];

For Unhiding:

[[self navigationController] setHidesBottomBarWhenPushed:NO];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰◇生如夏花灿烂 2024-12-04 13:07:26

.h.m

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

.h

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

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

.m

- (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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文