开发者

UIScrollView not working in IB

开发者 https://www.devze.com 2023-03-20 04:59 出处:网络
I have a UIScrollView that contains a UI开发者_JAVA百科View inside. The UIScrollView has paging enabled and is 320x500

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消