且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何阻止UIScrollView水平弹跳?

更新时间:2023-10-23 22:51:34

这很奇怪,因为每当我创建一个滚动视图框架和内容大小在任一维度的屏幕边界内,滚动视图不会在该方向上滚动(或反弹)。

That's strange, because whenever I create a scroll view with frame and content size within the bounds of the screen on either dimension, the scroll view does not scroll (or bounce) in that direction.

// Should scroll vertically but not horizontally
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
scrollView.contentSize = CGSizeMake(320, 1000);

您确定框架完全适合屏幕,contentSize的宽度不大于滚动视图的宽度?

Are you sure the frame fits completely within the screen and contentSize's width is not greater than the scroll view's width?