设置约束的UIScrollView [英] Setting constraints to UIScrollView

查看:177
本文介绍了设置约束的UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要一些帮助来限制设置为UIScrollView的。

Need some help to set constraints to UIScrollView.

我想在这里按照指示: https://开头开发商。 apple.com/library/ios/technotes/tn2154/_index.html (混合方式)。

I tried to follow the instructions here: https://developer.apple.com/library/ios/technotes/tn2154/_index.html (Mixed approach).

设置4双面约束的UIScrollView。
然后设置4双面约束的buttonContainer。

Setting 4 sided constraints to UIScrollView. Then set 4 sided constraints to the buttonContainer.

这个结果:

不过X code为给这个错误信息:

However xcode is giving this error message:

如果我看看X code的建议,无论是滚动视图不会滚动,或不显示在所有。

If I try xcode's recommendation, either the scrollview will not scroll, or it doesn't display at all.

任何想法有什么不对吗?

Any idea what's wrong here?

推荐答案

你正在告诉你做什么的信息。滚动视图设置其内容的大小,并成为通过其钉子视图(S)滚动视图本身的制约滚动。因此,这些约束必须提供足够的信息。还没有提供足够的内部约束来描述可滚动区域的高度和宽度(内容大小)

The messages you are getting tell you what to do. The scroll view sets its content size and becomes scrollable through the constraints pinning its subview(s) to the scroll view itself. Those constraints must therefore provide sufficient information. You have not provided enough internal constraints to describe the height and width of the scrollable area (the content size).

在换句话说,想限制从内而外的施胶buttonContainer的。那是你忽略了做什么。可以解决这个问题,例如,简单地通过给出buttonContainer的绝对宽度约束和绝对高度约束。而这些价值观必须的的比滚动视图本身的大小,如果内容是滚动的。

In other words, think of the constraints as sizing the buttonContainer from the inside out. That is what you have neglected to do. You can solve this, for instance, simply by giving the buttonContainer an absolute width constraint and an absolute height constraint. And those values need to be bigger than the size of the scroll view itself if the content is to be scrollable.

这篇关于设置约束的UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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