以编程方式隐藏 UITabBar
我有一个 UITabBar 控制多个视图,我想在发布版本中隐藏其中一个视图,但仍将其保留在项目中,因为我需要它用于测试目的。我怎样才能以编程方式做到这一点?它根本不应该对用户可见。谢谢!
I have a UITabBar which controls multiple Views and I would like to hide one of them from the release build, but still keeping it in the project as I need it for testing purposes. How can I do this programmatically? It should not be visible to the user at all. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,你可以这样做。尝试
[yourTabBar setHidden:YES];
还有[yourTabBar setAlpha:0];
如果您使用 Interface builder 来开发 UI,我做的另一件最好的事情就是移动适当的
UIView
(这里是UITabBar
)。在主nib
(或xib
)文件中。这样你就可以隐藏你想要隐藏的任何视图。同时它也是构建的一部分。Yes you can do this. Try
[yourTabBar setHidden:YES];
also[yourTabBar setAlpha:0];
One other best thing I do, if you are using Interface builder to develop your UI is to move the appropriate
UIView
(here itsUITabBar
). out of the mainnib
(orxib
) file. That way you are hiding whatever view you want to hide & at the same time it's part of the build.tabBar 初始化后,执行以下操作:
作用:
它获取 UITabBar 持有的当前视图控制器,从 itemNumberToRemove 指定的数组中删除项目,然后将剩余的项目放回 UITabBar 中。
After the tabBar is initialized do the following:
What this does:
It gets the current viewcontrollers held by the UITabBar, removes an item from the array specified by itemNumberToRemove and then puts the items remaining back in the UITabBar.