【发布时间】:2014-06-02 08:55:44
【问题描述】:
我在故事板的 3 个子视图中设置了多个 UILabels 和 UIButtons。在代码中,我为所有这些定义了自动布局约束,但是由于某种原因,当我运行应用程序时,我在故事板中定义的大小与代码中的约束冲突。
例如,一个子视图位于XIB中的0,0,高度为200,宽度为320,只是为了让我在编写代码之前对元素进行布局。情节提要中没有任何约束。
这个子视图中有许多 UILabel 和 UIButtons,它们的累积高度应该定义子视图的高度。这应该以 205pts 高度结束,但是日志显示冲突:
2014-06-02 16:45:38.506 discounter[11691:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSIBPrototypingLayoutConstraint:0x109390160 'IB auto generated at build time for view with fixed frame' V:[UIView:0x109389010(200)]>",
"<NSLayoutConstraint:0x109249510 V:[UIView:0x109389010(205)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x109249510 V:[UIView:0x109389010(205)]>
我已将所有视图设置为translatesAutoresizingMaskIntoConstraints = NO,所以我不知道为什么会发生这种情况。它似乎也发生在许多其他元素上,但我感觉这可能是相同的原因。
谁能帮忙?
谢谢!
【问题讨论】:
标签: ios autolayout xib