Interface Builder 中的 UITabBar - 太乱了?
我有一个视图控制器,我想在其上托管一个 UITabBar。 当用户单击不同的选项卡项时,我想显示不同的视图。 我有这个工作,但很难维护。
在 InterfaceBuilder 中,我只是创建了所有选项卡视图,然后隐藏它们。 在我的项目中,当用户单击其中一个选项卡项时,我只需将链接视图的隐藏属性设置为 false 即可使其显示。
不过,xib 看起来像是一场灾难,因为我有大约 4 个视图相互叠加。 为了让事情变得更容易,我在 InterfaceBuilder 中将视图的隐藏属性设置为 true,希望它能完全隐藏一些视图,以便更容易看到我在做什么。 InterfaceBuilder 只是将视图的不透明度更改为 30% 左右,因此您仍然可以看到它们全部层叠在一起。
我想知道是否有更好的方法来做到这一点。 如果可能的话,我不想以编程方式生成此 UI 的所有视图。
谢谢
I have a view controller and I want to host a UITabBar on it. When the user clicks on different tab items, I want to show different views. I have this working, but it's hard to maintain.
In InterfaceBuilder, I simply created all my tab views, hide them. In my project, when the user clicks on one of the tab items, I simply set the hidden property of the linked view to false so it appears.
The xib looks like a disaster though, because I have about 4 views layered on top of one another. To make things easier, I set the hidden property to true in InterfaceBuilder for the views, hoping it would completely hide some so it's easier to see what I'm doing. InterfaceBuilder simply changes the view's opacity to like 30% though, so you still see them all layered on top of one another.
I'm wondering if there is a better way to do this. I don't want to programatically generate all the views for this UI if possible.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
UITabBar
实际上应该是界面的“根”容器,然后它应该包含导航控制器和/或视图。我发现当 UI 本身变得难以在 Interface Builder 中处理时,最好的办法是切换到 Nib 窗口中的大纲视图(使用“视图模式”工具栏项),并访问 Nib 窗口层次结构中的元素。
UITabBar
should really be the 'root' container for your interface, and then it should contain navigation controllers and/or views.I find that when the UI itself becomes difficult to deal with in Interface Builder, the best thing to do is switch to outline view in the Nib window (use the "View Mode" toolbar item), and access the elements in the Nib window's hierarchy.