Sheehan Alam
Sheehan Alam

Reputation: 60859

UIScrollView not working in IB

I have a UIScrollView that contains a UIView 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?

Upvotes: 1

Views: 1682

Answers (3)

Nitin Alabur
Nitin Alabur

Reputation: 5812

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.

Upvotes: 9

user756245
user756245

Reputation:

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.

Upvotes: 2

foslock
foslock

Reputation: 3939

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!

Upvotes: 0

Related Questions