隐藏后显示标签栏
有没有办法在隐藏标签栏后显示它?
有一个标签栏导航结构。对于其中一个选项卡,我需要隐藏其第二级和第三级视图的选项卡栏。但同时我需要展示它的第一个和第四个视图。
我认为 Elements 中的示例代码在这里并不适用。
Is there any way to show a tab bar after it has been hidden?
Got a tabbar-nav structure. For one of the tabs, I need to hide the tab bar for its 2nd and 3rd level view. But at the same time I will need to show its 1st and 4th view.
The sample code from Elements isn't really applicable here I think.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我找到了一个很好的实用解决方案来解决这个问题 - 使 UITabBarController 的视图大于它需要的大小,以便实际的 UITabBar 被屏幕剪切。
假设标签栏视图通常填充其超级视图,这种事情应该起作用:
标签栏仍然显示,但它不在屏幕底部,所以看起来已经被隐藏了。
如果它导致额外的削波,它可能会对性能产生影响,但到目前为止,它似乎有效。
I've found quite a good pragmatic solution to this problem - make the UITabBarController's view larger than it needs to be, so that the actual UITabBar is clipped by the screen.
Assuming that the tab bar view normally fills its superview, this sort of thing should work:
The tab bar is still showing, but it's off the bottom of the screen, so appears to have been hidden.
It might have performance implications if it causes extra clipping, but so far, it seems to work.
推送到导航堆栈上的 UIViewController 可以执行如下操作:
编辑:在下面添加了额外的代码来处理框架。我不认为我特别推荐这个想法,因为它依赖于 UITabBarController 的内部默认视图结构。
在 UITabBarController 上定义以下类别:
然后,不要使用我最初建议的 tabBar.hidden 更改,而是执行以下操作:
显然,要确保实现已包含类别定义,以便知道“showTabBar”。
The UIViewControllers that are pushed onto the navigation stack can do the something like the following:
EDIT: Added additional code below to deal with the frame. Don't think I particular recommend this idea since it relies on the internal default view structure of a UITabBarController.
Define the following category on UITabBarController:
Then, instead of using the tabBar.hidden change I originally suggested, do the following:
Obviously making sure that the implementation has included the category definition so that 'showTabBar' is known.
您需要实现一个委托方法
,在其中您可以检查选择了哪个索引并显示选项卡栏
You need to implement a delegate method
Inside that you can check which index is selected and show the tab bar
我知道这是一篇旧帖子,但我认为下面的代码将有助于隐藏您不希望打开的视图控制器上的选项卡栏,并且具有当您从该视图控制器返回时自动读取选项卡栏的额外好处
I know this is an old post but i think the below code would help to hide the tabbar on the viewcontroller you don't want it on and has the added benefit of automatically readding the tabbar when you come back from that view controller