height and vertical position are ambiguous for UIStackView

孤者浪人 提交于 2019-12-07 03:22:30

问题


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.


回答1:


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




回答2:


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! ✨



来源:https://stackoverflow.com/questions/45428953/height-and-vertical-position-are-ambiguous-for-uistackview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!