我在 Interface Builder 的 Mac OS X 项目中有一个约束设置,如下所示:
H:|-(61)-[webView]
我想从我的代码中修改那个 IB 约束。我可以添加另一个约束,但是控制台会抱怨冲突,如下所示:
Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x102112320 H:|-(61)-[WebView:0x10230a1c0] (Names: '|':NSView:0x102362e90 )>",
"<NSLayoutConstraint:0x10063bab0 H:|-(0)-[WebView:0x10230a1c0] (Names: '|':NSView:0x102362e90 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x102112320 H:|-(61)-[WebView:0x10230a1c0] (Names: '|':NSView:0x102362e90 )>
Apple - Mac OS X - Cocoa Auto Layout Guide上的 Apple 文档指出“约束大多是不可变的......它在算法上很重要。更改常量比删除约束并添加新约束更有效...... "
如何从我的代码中修改前导空间约束?