0

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];
  • Check out the following link. It may help you to show and hide the tabbar. http://stackoverflow.com/questions/1209582/is-it-possible-to-hide-the-tabbar-when-a-button-is-pressed-to-allow-a-full-screen – iOS Aug 03 '11 at 11:44

1 Answers1

1

.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
  • 1
    Please **stop** dumping the same blob of code without context on so many answers. – Tim Post Aug 11 '11 at 10:19
  • @Tim Post i had spent about 3 hours to make this worked.so that i shared this all of them and for their who can get notification about my answer.ok i wont repeat it again.i forget to just passed the link.sorry.i wont make it this mistake again – Vijay-Apple-Dev.blogspot.com Aug 11 '11 at 10:27
  • 2
    You can pass the link in comments, which would be perfectly fine. Please also add some context to this answer, right now it's just a code dump which might make people overlook its usefulness. – Tim Post Aug 11 '11 at 10:30
  • @tim ok buddy.indeed i gave them as comment.from my next post i will do best as much as i can.thanku – Vijay-Apple-Dev.blogspot.com Aug 11 '11 at 10:58