1

I'm trying to set up a basic storyboard using the Single View Application template in Xcode. The Main.storyboard has one view controller in it. I can add a subview and I can size it fill its parent view, but if I add autlayout constraints, it thinks that the leading and trailing edges need to be set to -16 to fill the screen. If I set them to 0, like I would expect to work, then it has a 16 point gap on the sides of the view.

Does anyone know why it insists on having constraints set to -16?

enter image description here

1
  • The concept of right and left "margins" are new at iOS 8. Interface defaults to them when adding top, leading, trailing and bottom margins. Commented Oct 14, 2014 at 22:02

1 Answer 1

7

You've created constraints to the margins of the superview, not its edges. The edge of the view is 16 points from the margin.

This is new in Xcode 6. You can change this by altering the individual constraints (where it says the "item" as superview.margin or similar, in the attributes inspector) or by creating the constraints with the "use margins" box unchecked.

Sign up to request clarification or add additional context in comments.

3 Comments

I spent hours watching WWDC videos this summer and somehow missed that one... Thanks!
Is there anyway to set the constraint against the edge? Not that I'm planning to do it but it will be nice to know so I don't accidentally do it and have to debug. Thanks!!!
I don't follow - the answer is about setting the constraint to the edge

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.