Learning the basics of UIScrollView

Here is a scroll view guide from Apple

The basic steps are:

  1. Create a UIScrollView and a content view you want to put inside (in your case a UIImageView).
  2. Make the content view a subview of the scroll view.
  3. Set the content size of the scrollview to the frame size of the content view. This is a very important step that people often omit.
  4. Put the scroll view in a window somewhere.

As for the paging behavior, check out UIScrollView’s pagingEnabled property. If you need to scroll by less than a whole page you’ll need to play tricks with clipsToBounds, sort of the reverse of what is happening in this StackOverflow question.

Leave a Comment