UIScrollView won't scroll!
You need to set UIScrollView.contentSize
to match the total scrollable size, which is your subview frame size in this case.
As mentioned in the accepted answer, you must set the UIScrollView
's contentSize
property.
This can be done in Interface Builder.
- Select the scroll view
- Select the 'identity inspect' in Utilities pane on the right
- Under 'User Defined Runtime Attributes' click the '+' button
- Set the 'Key Path' value to 'contentSize'
- Set the 'Type' value to 'Size'
- Set the 'Value' value to '{width, height}' (eg: '{320, 600}')
Build and run and your scroll view will scroll.
The content inset does not affect scrolling. See What's the UIScrollView contentInset property for?
To scroll, you have to make the scrollview's frame smaller than its content, the contained image or view.