简体   繁体   English

即使我的contentsize小于其框架,我的ScrollView仍在滚动

[英]My ScrollView is scrolling even when my contentsize is smaller than its frame

I created this tree in an IB : 我在IB创建了这棵树:

  • UIViewController
    • UIView
    • UIScrollView (x=50 y=50 width=468 height=270) (background a visible color to differentiate) UIScrollView (x = 50 y = 50宽度= 468高度= 270)(背景为可见颜色以区分)

In my controller I explicit do theScrollView.contentSize = CGSizeMake(X,X) . 在我的控制器中,我明确执行theScrollView.contentSize = CGSizeMake(X,X)

When I run the program I still have vertical scrolls even when my contentsize height is smaller than the frame height. 当我运行程序时,即使我的contentsize高度小于框架高度,我仍然具有垂直滚动。 Using height values greater than 253 (254 258 ..) but still smaller than 270 make the scrolls appear. 使用大于253(254 258 ..)但仍小于270的高度值可使滚动出现。 Using < 253 the completely disappear. 使用<253,完全消失。

The horizontal axis has a weird behavior also. 水平轴也具有奇怪的行为。 The only way to make the horizontal scrolls appear is by setting the content > 471. It means that with 469 and 470 scrolls are still hidden. 使水平滚动条出现的唯一方法是将内容设置为>471。这意味着469和470滚动条仍被隐藏。

Why is this happening? 为什么会这样呢?

Check to see that autolayout is disabled in your storyboard. 检查以确保情节提要中禁用了自动布局。 This is to make sure that the content size isn't being reset after the line of code you mentioned. 这是为了确保您提到的代码行之后没有重置内容大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM