在的UIScrollView没有故事板​​与iOS 8规模类和自动布局工作 [英] UIScrollView in Storyboard not working with iOS 8 Size Classes and Autolayout

查看:137
本文介绍了在的UIScrollView没有故事板​​与iOS 8规模类和自动布局工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想创建一个的UIScrollView 仅在故事板,让我添加滚动标签比VC的高度了。下面是我所做的:

So I'm trying to create a UIScrollView only in storyboard that allows me to add scrolling labels for more than the height of the VC. Here's what I did:


  1. 创建的UIScrollView 即拿起任意宽度的大小任意高度VC

  1. Created UIScrollView that took up the size of the any width any height VC

制造约束0间隔在顶部,底部近邻,左,右

Made constraints 0 for spacing to nearest neighbor on top, bottom, left, and right

创建了一个观点,即是一个子视图的UIScrollView 通过相同的宽度任意宽度1500任意高度VC,但高(因为我只希望它垂直滚动)。

Created a view that is a subView of the UIScrollView with the same width as the any width any height VC but height of 1500 (because I only want it to scroll vertically).

设置约束近邻为0,仅左,上,右,并设置高度约​​束为1500。

Set constraints to nearest neighbor as 0 for ONLY left, top, and right and set the height constraint as 1500.

我把一个标签在顶部的子视图并在底部

I put a label at the top of the subView and at the bottom

当我在iPhone上运行6应用程序,因为我希望它不会垂直滚动。任何想法,为什么这是不工作?先谢谢了。

When I run the app on an iPhone 6, does not scroll vertically as I want it to. Any ideas why this is not working? Thanks in advance.

推荐答案

要获得你有针子视图(内容视图)来滚动视图的顶部,左侧,底部和右侧的滚动。
另外,你必须给它(到内容视图),明确的(=不相关的滚动视图)的高度和宽度,因为这些都是用于滚动视图计算出其含量的大小。
你的情况设置宽度等于VC主视图的宽度和高度为1500。
当宽度或高度比滚动视图尺寸更大,它会滚动。

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)

内容视图(钉在滚动型+高度1500,宽= MAINVIEW宽)+标签的限制。(例如:20 20从内容视图左上)

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

这篇关于在的UIScrollView没有故事板​​与iOS 8规模类和自动布局工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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