简体   繁体   English

将UIScrollView添加到Storyboard中的现有UIView

[英]Adding a UIScrollView to an existing UIView in Storyboard

I build an app using storyboards and I want to embed one of the view in a UIScrollView. 我使用故事板构建应用程序,我想在UIScrollView中嵌入其中一个视图。 Therefore to do so, I drag an drop the UIScrollView directly in the storyboard. 因此,为此,我直接在故事板中拖放UIScrollView。 I then adapt it size and position. 然后我调整它的大小和位置。

After that I select all my items and drag and drop them into the UIScrollView. 之后,我选择所有项目并将它们拖放到UIScrollView中。 My problem is that all my items' positions get messed up: they all align in the center of the UIScrollView so I have to reposition them myself. 我的问题是所有项目的位置都搞砸了:它们都在UIScrollView的中心对齐,所以我必须自己重新定位它们。

Is there any way I can keep the same layout? 有什么方法可以保持相同的布局吗?

Thanks a lot for your help! 非常感谢你的帮助!

Cheers 干杯

One way is to select the view, then go to editor -> embed in -> scroll view. 一种方法是选择视图,然后转到编辑器 - >嵌入 - >滚动视图。

For more complex things, temporarily disable autolayout, create a new empty viewcontroller, copy/paste all your subitems there, do your voodoo with your scrollview, paste them back when it's done. 对于更复杂的事情,暂时禁用自动布局,创建一个新的空视图控制器,在那里复制/粘贴所有子项,用滚动视图执行你的伏都教,完成后粘贴它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM