Search code examples
iosxcodeautolayoutinterface-builderxcode8

Auto-layout - StackView deleting existing constraints


I'm hardly learning to implement some iOS app screens in xCode Interface Builder with auto-layout.

I've already placed some elements with working constraints but I realize it would be more practical to group them into a vertical StackView.

At first it seems pretty easy as I did it for a previous screen. However, once I embed my elements in the StackView, all my margins constraints are gone ! Also, if I try to manually put back my constraints, they don't work at all and generate ambiguity.

I don't fully understand the way iOS UI builder works, so I'd gladly need some help.

See screenshots below.

Working constraints

All constraints are gone!


Solution

  • Constraints inside stack views can be quirky, but playing around with / experimenting with the characteristics can help.

    In particular, adjusting Alignment, Distribution, and Spacing can often do the trick.