【发布时间】:2016-12-07 21:00:07
【问题描述】:
我有 8 个标签(我们称它们为 a-h),它们应位于彼此下方。除了其他限制,我这样做:
a) top space to superview (3)
a) bottom space to b (22)
b) top space to a (22)
b) bottom space to c (22)
等等……
标签在 Y 轴上彼此相距 22 处。
这仅适用于,如果
c) bottom space to d (-22) !!!
d) top space to c (-22) !!!
因此,出于某种原因,AutoLayout 似乎想要将标签 d 放置在完全错误的位置上,我必须通过将约束设置为 -22 而不是 22 来调整它。我看不出原因。
我对标签的其他限制总是:
- align center y to (the input element next to it)
- leading space to superview
在每个标签旁边,我总是设置一个始终具有以下约束的输入元素(UITextField 或 UISwitch):
- trailing space to superview
- width
- height
- align center y to (their respective label)
这里可能会发生什么?谢谢 :) 注意:如果通过 -22 而不是 22 调整到错误的位置,一切看起来都很好 - 我只是被 -22 困扰。
编辑:8 行中有 2 行将 UISwitch 作为标签旁边的输入元素。 UISwitch 都只有Trailing space to superview 和align center y to (corresponding label) 约束
【问题讨论】:
标签: xcode autolayout ios-autolayout