Xcode 6 Beta 7: Storyboard Adds Extra Space on Right and Left Sides

Xcode 6 beta 7: storyboard adds extra space on right and left sides

iOS 8 adds the concept of “content margins” to UIView. The “What's New in Cocoa Touch” video from WWDC 2014 discusses content margins (under the title “Adaptive Margins”) starting at about 12m30s.

The default margins are 8 points on each side. Each end of a layout constraint can be relative to a view's margin instead of to the view's true edge (use File > Open Quickly to go to the definition of NSLayoutAttribute to see the possibilities).

Your constraint is “relative to margin”. When you create the constraint with the “Add New Constraints” popover, you can choose whether it's margin-relative or not:

constraint-popover

It always defaults to margin-relative; you have to turn the checkbox off every time you add constraints if you don't want them to be margin-relative.

You can't change whether a constraint is margin-relative in the quick-edit popover of your screen shot. Instead, double-click the constraint to bring up its full Attributes inspector. There, you can use the popup menus to select, for each end of the constraint, whether it's margin-relative or not:

constraint-attributes

Xcode 6 Interface Builder view is sized wrong

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.

iOS autolayout changes leading and trailing space

Double click the constraint and open it. There select first or second item and deselect "Relative to margin". Then set your constant as 0.

Xcode is showing -16 because it is calculating space with respect to a margin and not the edges.

Check following link for more info on margins. Editing Auto Layout Constraints

Sample Image

Auto Layout in Xcode 6 - Pinning view to edge of parent view creates -8 constraint

Before you add a new constraint, you will need to untick the "Constain to Margins". It is ticked by default.

Sample Image



Related Topics



Leave a reply



Submit