Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

height and vertical position are ambiguous for UIStackView

Autolayout cannot figure out the height or vertical position of a UIStackView despite having added subviews.

This is a pretty common error and "gotcha" so please see the answer below.

like image 584
SparkyRobinson Avatar asked Aug 01 '17 04:08

SparkyRobinson


2 Answers

If this is for a UIStackView make sure you are using addArrangedSubview and not addSubview

like image 105
SparkyRobinson Avatar answered Nov 09 '22 22:11

SparkyRobinson


For me I received the following error:

warning: Ambiguous Layout: Position and size are ambiguous for 'Button'.

Where the button was placed inside a stack view in Interface Builder. The problem was that I had checked "Hidden" in Interface Builder which meant Xcode was freaking out saying position and size are ambiguous. Just uncheck "Hidden" on the stack view and the warning will disappear... Magic! ✨

like image 35
ChrisJF Avatar answered Nov 09 '22 21:11

ChrisJF