Search code examples
iphonecocoatouch

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?


Solution

  • 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?