我有一个表格视图,并在单元格内设置了约束...我遇到了一个我不理解的约束错误。这是控制台打印:
2019-07-08 01:10:56.377538-0400 TableCellDynamicHeight[5827:393085] [LayoutConstraints] 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.
(
"<_UILayoutSupportConstraint:0x2835000a0 _UILayoutGuide:0x135e164f0.height == 20 (active)>",
"<_UILayoutSupportConstraint:0x283500000 V:|-(0)-[_UILayoutGuide:0x135e164f0] (active, names: '|':UIView:0x135e16310 )>",
"<NSLayoutConstraint:0x283517e80 V:[_UILayoutGuide:0x135e164f0]-(0)-[UITableView:0x13682e800] (active)>",
"<NSLayoutConstraint:0x2835001e0 V:|-(0)-[UITableView:0x13682e800] (active, names: '|':UIView:0x135e16310 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x283517e80 V:[_UILayoutGuide:0x135e164f0]-(0)-[UITableView:0x13682e800] (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
这是我的viewController和约束的样子:
答案 0 :(得分:3)
它基本上告诉您约束是冲突的,它必须自动删除其中的1个。
假设您的视图高度为40。然后,在其中放置一个视图,并告诉它从顶部开始为10,高度为20,从底部开始为0。这将导致它告诉您1个约束是错误的,必须删除才能起作用。因为您订购的高度为30,而实际高度为40。
另一件事是,在上述情况下,您实际上到底有10个倒数。这也会造成冲突,因为视图已经知道它是最底端的10,这意味着您基本上告诉编译器它的最底端是10的两次。