在大型 UIScrollView 中直观地排列子视图 [英] Visually arrange subviews in a large UIScrollView

查看:21
本文介绍了在大型 UIScrollView 中直观地排列子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中的一个屏幕必须是可垂直滚动的.它的内容或多或少是静态的,但它不适合手机的屏幕(因此是滚动视图).我使用 UIScrollController 作为顶视图,我想使用 Xcode 中的情节提要编辑器来布置其中的所有视图.我可以这样做吗?我显然可以在 UIScrollController 的可见部分放置东西,但是我可以在视觉上将更多视图放在首屏"吗?

One of the screens in my app has to be vertically scrollable. Its contents is more or less static, but it doesn't fit on the phone's screen (hence the scroll view). I'm using a UIScrollController as a top view, and I'd like to use the storyboard editor in Xcode to lay out all the views in it. Can I do that? I can obviously drop things on the visible part of my UIScrollController, but can I put more views "below the fold" visually?

推荐答案

还有另一种方法可以做到这一点,它与上面评论中链接中给出的答案不同,我认为这更容易,因为它可以让你看到你的以全尺寸查看整个内容并在 Storyboard 中进行设计.

There is another way to do it that is different from the answers given in the link in the comment above which I believe is easier because it allows you to see your whole content view at full size and design it in Storyboard.

  • 1) 放置一个 UIScrollView 作为控制器的根视图.
  • 2) 点击故事板中的 View Controller 并转到属性检查器并将大小更改为自由格式
  • 3) 单击故事板中的滚动视图并转到大小检查并更改宽度和高度到你需要的一样大.(2,000 x 4,000)
  • 4) 将 UIView 作为滚动视图的子视图,这将是您的内容视图您将在其中设计屏幕并将所有子视图.不要忘记将滚动视图的 contentSize 设置为viewDidLoad 中此视图的大小.
  • 5) 点击#4 中的 UIView 并在 Size Inspector 中设置 Struts 和 Springs此视图未调整大小 .
  • 6) 设计屏幕的其余部分

诀窍在于#3 &#5 将滚动视图的大小设置为非常大,以便您进行设计.当这个 viewController 被加载到 iPhone 中时,Struts &Springs 会将 scrollView 的大小调整为 iPhone 屏幕的大小,但 contentView 会保持较大.

The trick is in #3 & #5 setting the size of the scrollView to really large so you can design. When this viewController is loaded into the iPhone the Struts & Springs will resize the scrollView to the size of the iPhone screen, but the contentView will stay large.

这篇关于在大型 UIScrollView 中直观地排列子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆