2、http://stackoverflow.com/questions/24408256/scrollview-has-ambiguous-scrollable-content-height
3、http://natashatherobot.com/ios-autolayout-scrollview/
1、First step: need to create an UIView as a subview of the UIScrollView as described below:
UIViewController
UIView 'Main View'
UIView 'Container View'
[Your content]
UIScrollView
2、 The second step is to make the UIScrollView constraints. I did this with the top, bottom, leading and trailing constraints to its superView.
3、 Next I added the constraints for the container of UIScrollView and here is where the problem begins. When you put the same constraints (top, bottom, leading and trailing) the Storyboard gives a warning message:
"Has ambiguous scrollable content width" and "Has ambiguous scrollable content height"
Continue with the same constraints above, and just add the constraints "Equal Height" and "Equal Width" to your Container View in relation to the Main View and not to your UIScrollView. In other words the Container View's constraints are tied to the UIScrollView's superview.
After that you will not have warnings in your Storyboard and you can continue adding the constraints for your subviews.
---------------------------------------------------------------------------------------------------------
Add in the
UIScrollView
aUIView
(we can call thatcontentView
);In this
contentView
, set top, bottom, left and right margins to 0 (of course from thescrollView
which is thesuperView
); Set also align center horizontally and vertically;
Finished.
Now you can add all your views in that contentView
, and the contentSize
of the scrollView
will be automatically resized according with the contentView
.