简体   繁体   English

我仍然无法使我的UI滚动视图滚动! iOS版

[英]I Still Can't get my UI scroll view to scroll! iOS

So these are the steps I've done. 这些就是我已经完成的步骤。

I dragged a scroll view to my view controller in story board, declared it in the .h file and wired it up. 我将滚动视图拖到故事板上的视图控制器中,在.h文件中声明了它并进行了连接。

In the scroll view, I have 6 labels with sizes, (320, 38), (262,72), (300, 38), (285,31), (285,31), (285,31). 在滚动视图中,我有6个标签,尺寸分别为(320、38),(262,72),(300、38),(285,31),(285,31),(285,31)。

The scroll View itself has width of 320 and height of 184. 滚动视图本身的宽度为320,高度为184。

In my viewDidLoad method, I added : 在我的viewDidLoad方法中,我添加了:

[self.scroller setScrollEnabled:YES];
[self.scroller setContentSize:CGSizeMake(320,1000)];

What am I doing wrong or missing to make this scroll view scrollable?? 为了使滚动视图可滚动,我在做错什么或缺少什么?

EDIT: The viewController is used with Auto-layout. 编辑:viewController与自动布局一起使用。

Give an opportunity for the view layout to complete before calling setContentSize. 在调用setContentSize之前,有机会完成视图布局。 Move [self.scroller setContentSize:CGSizeMake(320,1000)]; 移动[self.scroller setContentSize:CGSizeMake(320,1000)]; to viewDidLayoutSubviews or viewDidAppear. 查看viewDidLayoutSubviews或viewDidAppear。

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

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