UIScrollView is able to automatically calculate it's content height and width, but you need to help it with this.
To do so you need to:
- Bound
contentView
(in your case) to all sides of superview (which is Scroll View
).
- Let
contentView
to calculate it's sizes. Here is a small mistake in your approach. You've set height of the contentView
equal to View
's height. So basically Scroll View
's contentSize.height is the same as View
's height. Which is not really what you want with dynamic content.
Usually you want to set width of the contentView
equal to View
's width and do not set contentView
's height. Instead you want to bind subviews of contentView
to their superview in such a way that their superview (contentView
) will calculate it's height automatically.
In your case I would bind:
pizza.jpg
to left-top-right of superview (height of pizza.jpg
will be set from intrinsic image size);
SAMPLE TITLE
label - left-right to superview; top to pizza.jpg
image;
Text View
- left-bottom-right to superview; top to SAMPLE TITLE
label; set a fixed height.
In this case contentView
will define needed height by itself. Scroll View
will set it's contentSize accordingly.
And your screen will be able to scroll vertically (it should be) ;)