4

Im working on tab bar application.

in all the view tabbar carried. ok.

but in a particular one view i didn't want to display my tabbar.

when i pushed my view to the next view, tab bar carried to that view also.

when i tried to hide this it shows white space for that view.

what to do.. thnaks in advance

iOS dev
  • 2,254
  • 6
  • 33
  • 56

3 Answers3

12

try....

MyViewController *myController = [[MyViewController alloc] init];
//hide tabbar
myController.hidesBottomBarWhenPushed = YES;
//add it to stack.
[[self navigationController] pushViewController:myController animated:YES];
janusfidel
  • 8,036
  • 4
  • 30
  • 53
2

UITabBar is a top level view which means that almost all over views are underneath it. Even UINavigationController seats bellow tabBar.

You could hide tabBar like this:

- (void)hideTabBar:(UITabBarController *)tabbarcontroller withInterval:(NSTimeInterval)delay {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:delay];
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+50, view.frame.size.width, view.frame.size.height)];
        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+50)];
        }
    }
    [UIView commitAnimations];
}

And then show it back on like this:

- (void)showTabBar:(UITabBarController *)tabbarcontroller withInterval:(NSTimeInterval)delay {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:delay];
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-50, view.frame.size.width, view.frame.size.height)];
        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-50)];
        }
    }
    [UIView commitAnimations];
}

UITabBar is of height 50 px by default. So you just need to set new height to the frame and animate it.

Borut Tomazin
  • 8,041
  • 11
  • 78
  • 91
1

You can add your view to the main window, and it will be over the tab bar:

[[myApp appDelegate].window addSubview:myView]; 
Antonio MG
  • 20,382
  • 3
  • 43
  • 62