6
votes

This question has been asked a lot and there are quite a few answers, but none of the answers I can find answer the following:

I have a UITabBarController

I want to hide the tab bar, so I call:

self.tabBarController.tabBar.hidden = YES

This removes the bar, but there is now an empty black box where the tab bar used to reside. I've tried resizing the frame of the ViewController that is currently being presented and it is always behind the black box left from the tab bar.

I also loop through all the subviews and hide them, no luck there.

Finally, I tried resizing the frame of the tabbar, and that doesn't do the trick either

Has anyone had any luck with this?

Also: hidesBottomBarWhenPushed doesn't work because the app isn't based on a UINavigationViewController, it is based on a UITabBarController.

This is an iPad app

2

2 Answers

8
votes

I had the same problem. Here is how I have gone about hiding the tab bar:

[self.tabBar removeFromSuperview];
    UIView *contentView;
    if ([[self.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]]) {
        contentView = [self.view.subviews objectAtIndex:1];
    } else {
        contentView = [self.view.subviews objectAtIndex:0];
    }
contentView.frame = self.view.bounds;

This is called from the tabBarController (I have it subclassed), but it does remove the tabBar and resizes the view to get rid of that black bar you are seeing now. If you don't have a subclassed tabBarController, I'm sure you could just change all instances of self to self.tabBarController and it should work the same.

I hope this helps

0
votes

It's not exactly an elegant solution, but you could resize the UITabBarController's view's height to extend past the bottom edge of the screen?