The relationship between UIScrollView and auto layout is different from other aspects of auto layout. Basically, if simple auto layout were allowed to operate, nothing would scroll. For example, if a subview of the scroll view were pinned in the normal way by a constraint to 10 points from the top of the scroll view, it would be absolutely pinned there; it would never move, no matter how the scroll view were scrolled.
To solve this problem, a UIScrollView that uses autolayout operates in a completely new way. Therefore when you say “I am using autolayout” you must prepare for things to operate very differently from before. You must either use a single scroll view subview with translatesAutoresizingMaskIntoConstraints = YES
, and an explicit content size, or else everything must have translatesAutoresizingMaskIntoConstraints = NO
and the content size will be deduced implicitly based on the constraints of the subviews.
This is very well explained in https://developer.apple.com/library/content/releasenotes/General/RN-iOSSDK-6_0/index.html