Xcode/Stackview, empty labels freaks out in stack view?

Viewed 1809

hopefully an easy one here. I have some labels and text fields. Between them, I want some empty labels, which will if needed to be error texts. But when I try to stack view it all, Xcode zooms out and nothing can be seen on the viewController. Anything else I need to change for it to work?

You can see a picture of it here before I hit stack view:

Xcode

The email label and text field are already in stack view, so are passwords, gentag passwords and label/button.

2 Answers

This certainly appears to be a bug. I duplicated your issue. I was able to solve it by setting a height/width to each empty spacer label, prior to adding it to my stack view. This doesn't make sense because when you add an object to a stack view it loses all of the constraints it has. None the less it resolved the issue:

enter image description here

Sounds like its just an auto layout issue (or lack of). Can be really messy, best to just keep playing around.

As you've already done, I would first put each label and its text field in a horizontal stack view and add constraints.

Then I'd add each of these stackviews to their individual warning labels in a vertical stackview and add constraints.

Finally I would combine all of the stackviews into one vertical stackview!

Related