如果我只想隐藏一种控制器的选项卡栏,如何使用 hidesBottomBarWhenPushed ?
我在使用 hidesBottomBarWhenPushed 时遇到了麻烦... 我将按顺序将三个控制器 - A、B 和 C - 推入导航控制器,并且我想在显示 B 时隐藏底部选项卡栏。(A 是选项卡栏控制器之一)
有人有想法吗?
I have gotten in trouble while using hidesBottomBarWhenPushed...
I will push three controllers – A, B, and C – into navigationcontroller in order, and I would like to hide bottom tab bar when B is shown.(and A is one of the tabbar controllers)
Does any one have ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在视图控制器 A(位于 tabBar 上)中,当需要呈现 B(不需要 tabBar)时:
在视图控制器 B 中,当需要呈现 C(再次需要 tabBar)时:
In view controller A (which is on the tabBar), when it comes time to present B (no tabBar wanted):
In view controller B, when it comes time to present C (tabBar wanted again):
我发现有时这已经太晚了,而不是在 viewDidLoad 中设置它。在 init 中设置它或覆盖 hidesBottomBarWhenPushed 以便对于没有底部工具栏的视图返回 YES。
Instead of setting it in viewDidLoad, I have found that sometimes this is too late. Set it in init or override hidesBottomBarWhenPushed to return YES for views with no bottom toolbar.
来自 hidesBottomBarWhenPushed 文档:
这意味着,如果您不一定知道视图控制器的推送顺序,则需要将堆栈中的所有视图控制器的 hidesBottomBarWhenPushed 设置为 false(topViewController 除外)。
因此,
这是 1 和 2 的一些代码)
3)我已将后退按钮操作重写为
From hidesBottomBarWhenPushed documentation:
This means that if you don't necessarily know the order the View Controllers will be pushed, you'll need all the view controllers from the stack to have its hidesBottomBarWhenPushed set to false except for the topViewController.
So what I do
Here's some code for 1 and 2)
3) I've overriden the back button action to