sta*_*cnz 3 xib ios autolayout
我已经设置了许多UILabels与UIButtons在故事板3子视图中.在代码中,我已经为所有这些定义了自动布局约束,但是由于某种原因,当我运行应用程序时,我在故事板中定义的大小与代码中的约束相冲突.
例如,一个子视图0,0位于XIB中,高度为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)]>
Run Code Online (Sandbox Code Playgroud)
我已将我的所有观点都设置为translatesAutoresizingMaskIntoConstraints = NO如此,以至于为什么会发生这种情况我感到很茫然.它似乎也发生在许多其他元素上,但我感觉它可能也是同样的原因.
有人可以帮忙吗?
谢谢!
Luk*_*ski 10
添加要在故事板中的代码中替换的那些约束,并检查它们的"在构建时删除"属性.像这样:

背景:
这是一种让您承诺Xcode将在代码中添加约束的方法,从而防止Xcode自动生成必要的约束.自动生成是必要的,否则运行时将无法确定如何呈现所讨论的视图.通常,您应该努力在故事板中定义所有约束.您还可以对代码执行IBOutlet约束,然后在运行应用程序时编辑其常量值,这样可以避免在代码中添加繁琐的约束.
| 归档时间: |
|
| 查看次数: |
1792 次 |
| 最近记录: |