Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Playlist Browser with Swift Building the Master and Detail Views Modifying the Detail View

Why uncheck constraints to margin ?

Can someone please explain why he unchecked "constraints to margin" option ?

2 Answers

Nick Kohrn
Nick Kohrn
36,935 Points

Hi Diego,

If you were to place an empty view controller in your storyboard and then drag any other kind of view onto that view controller, near the edges of the view controller, you would see lines appear near the edges of the view controller. You may also see your view sort of snap to those lines.

Apple provides those lines as a way to see where the margins of the view controller are. Since most applications don't have their content, such as words and titles, butted up flush against the side of the view controller, those lines provide a reference to allow some padding between the content of your application and the side of the screen.

When Pasan unchecked the setting to pin to margins, he was basically telling Xcode to not use the margin as a buffer between the playlist art and view controller edges, and to instead go ahead and pin the playlist art to the sides of the view controller. This causes the playlist art to span from one side of the screen to the other side of the screen without having space between the sides of the playlist art and edge of the screen. That enabled Pasan to achieve the look that he was going for.

When you first drag and drop in an element, Interface Builder fixes the element’s width and height, and pins its position relative to the top left corner of the superview so that resizing the window doesn’t move or resize the elements. By unchecking "constraints to margin", you are adding constraints, meaning your interface will react correctly to changes in size or orientation.

So the interface wouldn't react correctly to changes in size or orientation if i add constraints with "constraints to margin" checked ?