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

查看:183
本文介绍了在大型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作为滚动视图的子视图,这将是您的
    内容视图,您将在其中设计屏幕并放置所有
    子视图。不要忘记在viewDidLoad中将scrollview的contentSize设置为
    此视图的大小。

  • 5)单击#4中的UIView并在Size Inspector中设置Struts和Springs所以
    这个视图没有调整大小。

  • 6)设计屏幕的其余部分

  • 1)Place a UIScrollView as the root view of the controller.
  • 2) Click on the View Controller in storyboard and goto the Attribute Inspector and change the Size to Freeform
  • 3) Click on the Scroll View in storyboard and goto the Size Inspector and change the Width & Height to as big as you need. (2,000 x 4,000)
  • 4)Place a UIView as a subview of the scrollview, this will be your Content View where you will design your screen and put all your subviews. Don't forget to set the contentSize of the scrollview to the size of this view in viewDidLoad.
  • 5) Click on the UIView from #4 and in the Size Inspector set the Struts and Springs so this view is not resized .
  • 6) Design the rest of the screen

诀窍在#3& #5将scrollView的大小设置得非常大,以便您可以进行设计。当这个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天全站免登陆