24

I have a viewcontroller that it implement UITabbarViewController, and I want to hide the tab bar and override it by myself,

self.tabBar.hidden = YES;

the tab bar disappeared BUT there is a blank area(the blue one) at the bottom of the view. I dont want the blank area , how can I fix this? Thank you.

edit: the blue area is:

self.view.backgroundColor = [UIColor blueColor];
jxdwinter
  • 2,339
  • 6
  • 36
  • 56

4 Answers4

66

We've done exactly the same in our application. To hide the default TabBar, simply override the hidesBottomBarWhenPushed method in your parent view controller (or in every view controller in your App)

#pragma mark - Overriden UIViewController methods
- (BOOL)hidesBottomBarWhenPushed {
    return YES;
}

EDIT: This value can also be set from Storyboard:

enter image description here

redent84
  • 18,901
  • 4
  • 62
  • 85
  • 1
    Set it in storyboard if you can. I did it in the viewcontroller but then when pressing the back button, tab bar was still hidden. Tried to do the reverse code and bring it back but no luck. – levibostian Aug 01 '15 at 00:11
  • 1
    I tried this, didn't work. Neither the code version nor the Storyboard version. I set it for every view controller in my app (since it's not 100% clear which view controller I'm supposed to add it to). Zero effect. My tab bar controller is embedded in a Container, which is in a View Controller that is itself embedded in a Container in another view controller. This nesting may be the source of the problem. There is only one TabBar controller in my app. – Bill Patterson Aug 29 '15 at 16:55
  • 2
    @BillPatterson this only works for view controllers embedded in a `UINavigationController`. You will have `UITabViewController` -> `UINavigationController` -> 'MyViewController'. And you set the `hidesBottomBarWhenPushed` to `YES` in MyViewController – redent84 Aug 30 '15 at 14:15
2

My UITabBarController is housed within a container view. Checking "Hide Bottom Bar on Push" was not working for me. Instead I created a subclass of the tab bar controller and hid the tab bar programmatically.

class FooTabBar: UITabBarController {
  override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    self.tabBar.isHidden = true
  }
}
Mark Suman
  • 10,430
  • 2
  • 27
  • 23
1

I don't think there's an easy way to fix this because UITabbarViewController is probably your super view and all "inner" views' height = screenHeight - tabBarHeight - navBarHeight.

Maybe you can try to resize your inner view controller manually but then I think you might have problems with Apple's AppStore submission process, because I think this violates general iOS user experience.

martin
  • 93,354
  • 25
  • 191
  • 226
1

And this is how you'd do the override (UIViewController) in Swift:

override var hidesBottomBarWhenPushed: Bool {
    get { return true }
    set { super.hidesBottomBarWhenPushed = newValue }
}
Markus Rautopuro
  • 7,997
  • 6
  • 47
  • 60