我有一个奇怪的案例 - 我会尝试孤立,但我想在此期间我会提出一个问题。我有一个有高度约束的UILabel。当我尝试将高度设置为0时,我得到了这个(不是超级有帮助的)错误:
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)
(
"<NSLayoutConstraint:0x7b9b5d90 V:[UILabel:0x7b9c6cf0(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7b9b5d90 V:[UILabel:0x7b9c6cf0(0)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
对我来说令人困惑的部分是错误说“无法同时满足约束”,但只显示一个约束。它也可以通过打破这个单一约束来恢复。
约束如何与自身冲突?