UIView作为IB中的容器?

发布于 2024-12-08 23:30:32 字数 150 浏览 0 评论 0原文

有没有办法将标签和按钮等组件放置在 IB 中的 UIView 等容器内,仅用于将这些组件作为一个整体移动?我不需要容器具有任何功能,只需作为在 IB 内拖动一组 IB 组件的简单方法即可。我尝试将组件放入 UIView 中,但很难选择 UIView 来进行拖动。

谢谢!

Is there a way to place components like labels and buttons inside a container like a UIView in IB solely for the purpose of moving those components around as a whole? I don't need the container to have any functionality, just serve as an easy way to drag around a group of IB components inside IB. I tried putting components inside a UIView but the UIView is not easily selectable to drag around.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

痴情换悲伤 2024-12-15 23:30:32

是的,有,你只需要确保在 IB 中使用元素/对象的层次结构

我的意思是确保容器视图中想要的每个对象都是容器视图的子对象(显示为缩进)下)在导航窗格中。 (确保您的左侧导航器窗口显示 - 通过单击最左侧的项目查看 xcode 右上角的分段控件)。

在导航器中,您将看到列出的所有对象将您想要的对象拖动到容器中,直到使它们缩进到容器下方(UIVIEW),我发现这有时有点棘手。所有子项都位于容器视图中后,通过在导航器中单击容器来选择容器,然后在视图窗格(中间)中将容器 UIView 拖动到所需的位置。

这对于将事物分组以及以编程方式隐藏、显示、移动或动画一组对象非常有帮助。 (FWIW,我发现隐藏/显示视图的最佳方法是使容器 UIView 的高度或宽度为 0。然后当您希望它可见时重置为正常宽度。我在将其标记为隐藏时遇到了麻烦)。确保对象和 UIView 的背景清晰(如果适用)。

祝你好运,希望这有帮助。

Yes, there is, you just have to make sure you use the hierarchical structure of elements/objects in your IB

What I mean is make sure that each of the objects you want in your container view are CHILDREN of the container view (visible as indented beneath) in the Navigator Pane. (Make sure your left navigator window is showing -- see segmented control top right of xcode -- by clicking the left most item).

Within the navigator you will see all of your objects listed Drag the objects you want in your container until you make them indent below the container (UIVIEW) this is sometimes kind of tricky I find. Once all of the children are in the container view select the container by clicking on it in the navigator and then in the view pane (in the middle) drag the container UIView where you want it.

This is very helpful for grouping things together as well as hiding, revealing, moving or animating a group of objects programatically. (FWIW, I find the best way to hide/reveal the view is to make the container UIView have a height or width of 0. Then reset to normal width when you want it visible. I've had trouble marking it hidden). Make sure the background of your objects and UIView are clear (if appropriate).

Good luck hope this helps.

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