UIScrollView - Need Constraints for x position/width, Need Constraints for y position/height

Viewed 9736

I have a view hierarchy that looks like this (based on other answers and Apple's advanced AutoLayout guide for working with UIScrollView):

enter image description here

The 2 steps required for ScrollView are:

  1. Set up constraints for position and size (frame) of ScrollView: The same way you do it with any other view.
  2. Set up constraints for content size: By making sure that there are constraints from the ScrollView's subviews touching all edges (leading, trailing, top, bottom) of the ScrollView, if you're doing this in interface builder and not programmatically.

Step 1 worked fine at first and this was the result:

enter image description here

enter image description here

No problems with position and size as expected. I just need to define the content size (content height and content width) now in Interface Builder with Step 2.

Now I add the constraints touching all 4 edges of the ScrollView like so:

enter image description here

Suddenly, the ScrollView doesn't know it's position and size (frame) anymore.

enter image description here

I've looked at other answers and followed the various steps, but can't seem to resolve this issue. Sorry I'm not able to post Storyboard screenshots because of privacy issues

2 Answers
Related