我有一个UICollectionViewCell
自动布局约束。它按方面工作,但我的应用程序打印了很多关于未满足约束的警告:
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:0x7f9e650c50f0 UILabel:0x7f9e650c10c0'Toz Kat Elek >30'.top == UIView:0x7f9e650c0fd0.topMargin - 8>",
"<NSLayoutConstraint:0x7f9e650c51e0 UIView:0x7f9e650c17f0.top == UILabel:0x7f9e650c10c0'Toz Kat Elek >30'.top + 20>",
"<NSLayoutConstraint:0x7f9e650c5280 UIView:0x7f9e650c0fd0.bottomMargin == UIView:0x7f9e650c17f0.bottom - 8>",
"<NSAutoresizingMaskLayoutConstraint:0x7f9e650d8550 h=--& v=--& V:[UIView:0x7f9e650c0fd0(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f9e650c5280 UIView:0x7f9e650c0fd0.bottomMargin == UIView:0x7f9e650c17f0.bottom - 8>
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.
我尝试了很多不同的组合来找出问题的根源。在使用 Debug View Hierarchy 检查我的视图层次结构时,我发现有一个我没有添加的 UIView 并且这个 UIView 会导致警告消息。
那么如何才能摆脱这些警告信息呢?
更新
这是我的视图层次结构: