1
votes

I am using autolayout in Xcode and am creating a fairly tall (1300px) ViewController with a uiscrollview to navigate up and down. I made the viewcontroller freeform so its dimensions are [375,1300]. I then incorporated the scrollview, added the content view as well as all the subviews & constrained everything, leaving no constraint errors. At runtime there are no errors, but everything is all smushed into the normal screen size when I intended for it to be very tall (~1300px) and scrollable. Any clue as to what I am doing wrong?

Below is a diagram showing the issue where:

  1. The Outer Black Blox is the ViewController's view

  2. The Inner Black Boxes are subviews

  3. and The Blue Box is what is displayed on the screen

picture describing my question

2
I think you'll need to describe the constraints you used. It sounds like your constraints might involve the scroll view rather than it's content view, or something like that.Caleb
Remove the constraint that makes the contentView's height the same as the parent view.Brandon

2 Answers

2
votes

Yes, your correct @Ryan Cocuzzo. I think you need to set sub view priority from 1000 to 250. See below screen shots.

1) Select height constraint of the subview

2)Then go to show to size inspector

enter image description here

3) Now change the priority constraint from 1000 to 250.

enter image description here

4)Finally you get like this

enter image description here

0
votes

Make sure the following are true:

  1. The 4 content views are subviews of the UIScrollView, not your view controller.
  2. The autolayout constraints on the 4 content views must reference the UIScrollView only, not the view controller's view.
  3. The 4th box cannot have a bottom constraint.

It looks like the 4th box has a constraint to make it's bottom align with the bottom of the view controller's view. This would force the other views to smush up together. The 4th box also cannot have a bottom constraint so that the scrollview can resize itself to encompass it's subviews.