HandyAutoLayout
HandyAutoLayout copied to clipboard
重复添加constraint后警告Unable to simultaneously satisfy constraints.
code
[self.view addConstraints:[self.view1 constraintsSize:CGSizeMake(50, 30)]];
[self.view addConstraints:[self.view1 constraintsTopInContainer:10.0f]];
[self.view addConstraints:[self.view1 constraintsTopInContainer:20.0f]];
console
2016-09-02 19:53:50.192 FaiChouTest[3223:179657] 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.
(
"<NSLayoutConstraint:0x7faad0d452c0 UIView:0x7faad306b8f0.top == UIView:0x7faad3017670.top + 10>",
"<NSLayoutConstraint:0x7faad0d2daf0 UIView:0x7faad306b8f0.top == UIView:0x7faad3017670.top + 20>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7faad0d2daf0 UIView:0x7faad306b8f0.top == UIView:0x7faad3017670.top + 20>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
这样会使得添加动画变得困难,我们需要手动移除原先的constraint,再添加之。 我们可以在原封装方法里添加判断。
Masonry里对于动画,格外添加了一个方法mas_updateConstraints
。
I am new to autoLayout.