在为 NSLayoutConstraints.constant 赋值后收到 'unable to simultaneously satisfy constraints' 消息
Got 'unable to simultaneously satisfy constraints' message, after assigning value to NSLayoutConstraints.constant
我必须在执行期间更改约束值(即 height
值),从 19 更改为 45。
为此,我添加了约束 属性。
@IBOutlet weak var cnst: NSLayoutConstraint!
然后我写了下面的
cnst.constant = 45
然后我收到这条消息:
2016-08-04 11:19:49.352 IMOZOMO[45034:538195] 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:0x7ff278c27e70 V:[UIView:0x7ff278c27f40(45)]>",
"<NSLayoutConstraint:0x7ff27a9b1ee0 V:[UIView:0x7ff278c27f40(19)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff278c27e70 V:[UIView:0x7ff278c27f40(45)]>
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.
好像之前的属性依然存在,指定对象的高度没有变化。我以为高度为 19 的约束可能会消失。
如何更改 NSLayoutConstraint 的常量值?
如错误所述,您的高度约束值 = 45 存在冲突。
现在,在高度 19 上,它可能满足层次结构,但在 45 上,它是冲突的。
解决方案:
尝试在界面生成器中将高度限制设置为 45,它应该会立即显示错误。
我必须在执行期间更改约束值(即 height
值),从 19 更改为 45。
为此,我添加了约束 属性。
@IBOutlet weak var cnst: NSLayoutConstraint!
然后我写了下面的
cnst.constant = 45
然后我收到这条消息:
2016-08-04 11:19:49.352 IMOZOMO[45034:538195] 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:0x7ff278c27e70 V:[UIView:0x7ff278c27f40(45)]>",
"<NSLayoutConstraint:0x7ff27a9b1ee0 V:[UIView:0x7ff278c27f40(19)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff278c27e70 V:[UIView:0x7ff278c27f40(45)]>
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.
好像之前的属性依然存在,指定对象的高度没有变化。我以为高度为 19 的约束可能会消失。
如何更改 NSLayoutConstraint 的常量值?
如错误所述,您的高度约束值 = 45 存在冲突。
现在,在高度 19 上,它可能满足层次结构,但在 45 上,它是冲突的。
解决方案:
尝试在界面生成器中将高度限制设置为 45,它应该会立即显示错误。