Lorenzo
Lorenzo

Reputation: 447

Problem with UIScrollView inside another UIView

I have this UIScrollView inside another UIView, not occuping the entire area (all this is initialized via nib file). I added some content to the scroll view, but whenever I scroll it, the UIScrollView content area moves outside the ScrollView frame, over the UIView area not designated for displaying it.

Shouldn't it remain inside its frame even when I scroll it?

Upvotes: 5

Views: 1608

Answers (3)

surajz
surajz

Reputation: 3611

Make sure you have setContentSize. And also set the frame size of the uiviews inside the uiscrollview correctly when you add them.

Here is a sample code of it http://developer.apple.com/library/ios/#samplecode/Scrolling/Introduction/Intro.html

Upvotes: 0

meronix
meronix

Reputation: 6176

try to set the clipsToBounds to YES, it may be that:

yourViewController.clipsToBounds = YES;

if not... fbreto is right, post your code...

Upvotes: 0

occulus
occulus

Reputation: 17012

It may be that the clipsToBounds property of your UIScrollView is set to NO. Check the setting in IB, or you can set it in code like so:

scrollView.clipsToBounds = YES;

Failing that, double check that your UIScrollView has exactly the bounds you think it does. Is there any autoresizing flag stuff going on that might be changing the scroll view's bounds?

Upvotes: 6

Related Questions