Search code examples
uiscrollviewautolayoutuitextviewios-autolayout

Why does the UIScrollView calculate a massive contentSize with AutoLayout?


So I've followed all the best practices with respect to having a scrollable content view that works with autolayout (first have one direct subview of UIScrollView, add all the pin constraints, etc), especially when you have a UITextView (i.e. disable scrollingEnabled on the text view)

for example here, or just googling UIScrollView and Autolayout you'll find a lot of tutorials that rehash the same thing.

I've done all this, but am noticing that the scrollView is calculating a contentSize that does not match the contentView's height. I have no idea why this is:

enter image description here

I expect moderators to point out other questions. I looked around and nothing really matched what I'm seeing...


Solution

  • For completeness, it was DonMag's comment that solved it. Unknowingly, the constant was not set to 0, which explains why the contentSize.height WAS 680pt larger than the content.