我的布局如下:
Table View (dynamic prototypes, row: automatic height and estimate)
Table View Cell (row height: default)
Content View
Stack View (axis: horizontal, alignment: center, distribution: fill)
Image View (height: 70, width: 70)
Label
UITableView具有其上级视图的所有4个约束(顶部,底部,前导和尾随)。相对于其超级视图,UIStackView也是如此。
问题在于,行高度不是在接口构建器内部计算的,实际上它指向以下冲突的约束:
bottom = Stack View.bottom
height = 70
Stack View.top = top
centerY = Image View.centerY
我发现这种布局非常简单,这使我感到困惑,为什么它不起作用。
最佳答案
如果您当前的情节提要板看起来像前两个图像:
然后,问题在于您在图像视图70
上设置了Height约束,但是表视图单元格的默认高度仅为44
。这就没有足够的空间来进行自动布局以满足所有约束。
如果将“行高”(在“大小检查器”窗格中)更改为71
,则冲突的约束将消失: