UIScrollView 不会滚动!

UIScrollView won#39;t scroll!(UIScrollView 不会滚动!)

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

问题描述

在 IB 中,我有我的 UIView.然后我有一个带有 UIScrollView 作为子视图的子 UIView.然后 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 不会滚动!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:UIScrollView 不会滚动!

基础教程推荐