问题描述
我有一个 UIScrollView
在界面生成器中创建了一堆 UITextView
和 UIImageView
已添加的对象。我有它连接到 IBOutlet
和 - (void)viewDidLoad
我设置其内容大小为 1200x2000
。用户交互启用,多点触控,滚动启用并显示垂直和水平滚动指示器均设置为 YES
。当我在iOS模拟器中启动应用程序时,它不滚动。什么可能是这种行为的原因?
I have a UIScrollView
created in interface builder with a bunch of UITextView
and UIImageView
objects already added. I have it connected to an IBOutlet
, and under -(void)viewDidLoad
I set its content size to 1200x2000
. User interaction Enabled, Multitouch, Scrolling Enabled and shows vertical and horizontal scroll indicators are all set to YES
. When I launch the app in the iOS simulator, it doesn't scroll. What could possibly be the cause of this behavior?
推荐答案
-
viewDidLoad即将推出。您必须等到视图的布局发生之后。请尝试在viewDidAppear中设置contentSize。
viewDidLoad is to soon. You must wait until after the layout of the views has taken place. Try setting the contentSize in viewDidAppear.
是否使用autolayout?如果是这样,请检查以下答案(并忘记1.):
。
Are you using autolayout? If so, check out the following answer (and forget 1.):UIScrollView doesn't use autolayout constraints.
这篇关于UIScrollView不滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!