UIScrollView不滚动? [英] UIScrollView Not Scrolling?

查看:91
本文介绍了UIScrollView不滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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?

推荐答案


  1. viewDidLoad即将推出。您必须等到视图的布局发生之后。请尝试在viewDidAppear中设置contentSize。

  1. 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.):
UIScrollView不使用自动布局约束

Are you using autolayout? If so, check out the following answer (and forget 1.): UIScrollView doesn't use autolayout constraints.

这篇关于UIScrollView不滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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