我如何知道哪些约束冲突?
2014-10-26 12:31:55.713 MyApp[17769:2430918] 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:0x79646340 V:[UIImageView:0x796475f0]-(0)-| (Names: '|':UIView:0x79641bc0 )>",
"<NSLayoutConstraint:0x796463a0 V:[UILabel:0x79636150'my settings']-(19)-[UIImageView:0x796475f0]>",
"<NSLayoutConstraint:0x79646430 V:|-(20)-[UILabel:0x79636150'my settings'] (Names: '|':UIView:0x79641bc0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x79640030 h=-&- v=-&- UIView:0x79641bc0.height == _UITableViewHeaderFooterContentView:0x79639c70.height>",
"<NSLayoutConstraint:0x7963a190 'UIView-Encapsulated-Layout-Height' V:[_UITableViewHeaderFooterContentView:0x79639c70(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x796463a0 V:[UILabel:0x79636150'my settings']-(19)-[UIImageView:0x796475f0]>
答案 0 :(得分:0)
首先让我说修复这些并不容易。我在IB中创建了大多数东西,所以我通常的方法是清除所有约束并重建它们。
在您的情况下,您可能会有一个更简单的答案。其中一个约束是<NSAutoresizingMaskLayoutConstraint:0x79640030 …
。这让我怀疑视图是动态添加的。找到那个观点。
在致电NO
(translatesAutoresizingMaskIntoConstraints
)之前将see设为-addSubview:
。
此时(希望)视图会加载,但你还没有完成。他们动态添加的视图将不受约束。您需要以编程方式添加任何所需的约束see。