问题描述
在IB中我有我的UIView。然后我有一个子UIView,UIScrollView作为子视图。然后UIScrollView有一个子UIImageView。 UIScrollView和UIImageView的大小相同。它们比它们是子视图的UIView大得多。我认为这会使滚动工作。它没有。滚动视图是否需要某种代码?
In IB I have my UIView. Then I have a sub-UIView with a UIScrollView as a sub view. Then the UIScrollView has a sub-UIImageView. The UIScrollView and UIImageView are the same size. They're much bigger than the UIView of which they are subviews. I assumed this would make scrolling work. It doesn't. Is some sort of code required for scroll views to work?
推荐答案
您需要设置 UIScrollView.contentSize
匹配总可滚动大小,在这种情况下是您的子视图帧大小。
You need to set UIScrollView.contentSize
to match the total scrollable size, which is your subview frame size in this case.
这篇关于UIScrollView不会滚动!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!