height and vertical position are ambiguous for UIStackView

SparkyRobinson picture SparkyRobinson · Aug 1, 2017 · Viewed 8.5k times · Source

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.

Answer

SparkyRobinson picture SparkyRobinson · Aug 1, 2017

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