In IB I have my UIView. Then I have a sub-UIView with a UIScrollView as a sub view. Then the UIScrollView has a sub-UIImageView. The UIScrollView and UIImageView are the same size. They're much bigger than the UIView of which they are subviews. I assumed this would make scrolling work. It doesn't. Is some sort of code required for scroll views to work?
You need to set | |||||||||||||||||||||
|
To scroll, you have to make the scrollview's frame smaller than it's content, the contained image or view. | |||||||||||||||||
|
I placed all the content of my scrollview in IB. (buttons, labels, text fields, etc). The full size is 500 tall. I then resized it to 436 tall in IB. Then in code, I put this is viewDidLoad:
So that leaves 64 pixels that I can scroll. It works perfectly. I also placed "UIScrollViewDelegate" in the <> braces of @interface for my .h file and tied the delegate outlet of the scrollview to File's owner in IB. | |||
|
Scroll view works with this: Happy days!! | |||
|
This might be obvious to most, but I spent ages wondering why my UIScrollView wouldn't scroll so I'm posting what was stopping me in case it helps anyone else: The UIScrollView has to be of the dimensions of the visible area in which you wish it to be presented and not the size of it's contents. Ridiculous on my behalf I know, but just in case it helps someone. | |||
|
As mentioned in the accepted answer, you must set the This can be done in Interface Builder.
Build and run and your scroll view will scroll. The content inset does not affect scrolling. See What's the UIScrollView contentInset property for? | |||
|
more, did you enable scrolling? look at the property
| |||
|