Interface Builder 中的 UITabBar - 太乱了?

发布于 07-26 15:18 字数 444 浏览 7 评论 0原文

我有一个视图控制器,我想在其上托管一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

來不及說愛妳2024-08-02 15:18:55

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.

帥小哥2024-08-02 15:18:55

我通常不喜欢在 nib 文件中创建各种隐藏视图,正是因为事情变得非常混乱,并且很容易无意中单击并拖动您不想要的内容。

在这种情况下,我要做的是将隐藏视图分解为单独的笔尖,然后让控制器加载并将它们根据需要放置到视图中。 这种方法的另一个优点是它仅在需要时加载视图 - 使视图整体更轻。

I generally dislike creating all sorts of hidden views within a nib file, precisely because of how messy things get and how easy it becomes to inadvertently click and drag something you don't intend to.

What I'll do instead in that instance is break out the hidden views into separate nibs, and have the controller load and place them into the view on an as-needed basis. Another upside to this approach is that it loads views only when they're needed - making the view lighter-weight overall.

没︽人懂的悲伤2024-08-02 15:18:55

我也有同样的问题,但我没有使用“隐藏”复选框,而是使用“大小”检查器查找要“隐藏”的控件,然后在 X 值之前添加 99。 这会将其移出屏幕,并且通过删除 99 可以轻松地将其移回原始位置。不太理想,但它可以工作......只需记住在完成后将它们移回原来的位置即可。

I have the same problem but instead of using the Hidden checkbox, I go the Size inspector for the controls I want to "hide", and then just put a 99 before the X value. This moves it off the screen, and it's easy to move it back to the original location by removing the 99. Not ideal, but it works... just remember to move them back when you're done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文