I have a UIScrollView that contains a UI开发者_JAVA百科View inside.
The UIScrollView has paging enabled and is 320x500
The UIView is 320x480
My UIView doesn't scroll in the simulator or on the device. What am I doing wrong?
To make the UIScrollView
scroll, the ScrollView.contentSize
should be larger than the ScrollView.frame.size
If you want it to scroll only up-down, make the ScrollView.contentSize.height
greater than the ScrollView.frame.size.height
(and so on for scrolling sideways or both ways)
You'll have to set the content size programmatically.
You probably didn't set the contentSize
property of the UIScrollView
, which is a CGSize
.
Set this property with the content view frame's size.
Also your UIView
isn't larger than the scroll view, but it should at least bounce the scroll.
Make sure you have an object to be the UIScrollView's delegate, and that it implements the required methods for panning. Read more about it here:
UIScrollView documentation
Hope that helped!
精彩评论