UIScrollView in Storyboard not working with iOS 8 Size Classes and Autolayout

三世轮回 提交于 2019-11-28 03:12:49

To obtain the scroll you have to pin the sub view (the "content view") to the top, left, bottom and right of the scrollview. In addition you have to give it (to the "content view") an explicit (=not related to the scroll view) height and width because these are used by the scrollview to calculate its content size. In your case set the width equal to the VC main view width and the height to 1500. When width or height are bigger than the scrollview size, it will scroll.

Scroll view constraints (pinned to main view)

Content view (pinned to scrollview + height 1500, width=mainview width) + label constraints (as an example: 20 20 from content view top left)

For an easier visualisation, I created a video on how to do that.

Video on how to create a vertical-only scrollview in iOS

Have you set the contentsize bigger than the screen itself? In your case, just bigger in height.

As Apple Documentation says: "You must set the contentSize property to the size of the scrollable content. This specifies the size of the scrollable area."

The only solution is add constraints to the right and bottom of the bottom subview of scroll view's child view. Also check if all the views from top to bottom have got proper constraints along with height. For the scroll view ' s wrapper view add equal width and equal height constraint to its superview.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!