iOS TabbarViewController hide the tab bar

好久不见. 提交于 2019-11-27 12:10:15

问题


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];

回答1:


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:




回答2:


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.




回答3:


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

override var hidesBottomBarWhenPushed: Bool {
    get { return true }
    set { super.hidesBottomBarWhenPushed = newValue }
}



回答4:


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


来源:https://stackoverflow.com/questions/15296065/ios-tabbarviewcontroller-hide-the-tab-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!