iOS TabbarViewController 隐藏标签栏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15296065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS TabbarViewController hide the tab bar
提问by jxdwinter
I have a viewcontroller that it implement UITabbarViewController, and I want to hide the tab bar and override it by myself,
我有一个视图控制器,它实现了 UITabbarViewController,我想隐藏标签栏并自己覆盖它,
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];
回答by redent84
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)
我们在我们的应用程序中做了完全相同的事情。要隐藏默认 TabBar,只需覆盖hidesBottomBarWhenPushed
父视图控制器(或应用程序中的每个视图控制器)中的方法
#pragma mark - Overriden UIViewController methods
- (BOOL)hidesBottomBarWhenPushed {
return YES;
}
EDIT: This value can also be set from Storyboard:
编辑:这个值也可以从 Storyboard 设置:
回答by martin
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
.
我认为没有一种简单的方法可以解决这个问题,因为UITabbarViewController
可能是您的超级视图和所有“内部”视图的 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.
也许您可以尝试手动调整内部视图控制器的大小,但我认为您可能在 Apple 的 AppStore 提交过程中遇到问题,因为我认为这违反了一般的 iOS 用户体验。
回答by Markus Rautopuro
And this is how you'd do the override (UIViewController
) in Swift:
这就是您UIViewController
在 Swift 中执行覆盖 ( ) 的方式:
override var hidesBottomBarWhenPushed: Bool {
get { return true }
set { super.hidesBottomBarWhenPushed = newValue }
}
回答by Mark Suman
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.
MyUITabBarController
位于容器视图中。检查“推送时隐藏底部栏”对我不起作用。相反,我创建了标签栏控制器的子类并以编程方式隐藏了标签栏。
class FooTabBar: UITabBarController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.tabBar.isHidden = true
}
}