使用 NSLayoutConstraint 时出错
Error using NSLayoutConstraint
我有 2 个故事板。第一个 - 名为 "st1" 的 tableViewController 具有带有 5 个标签的静态单元格、5 个文本字段和 2 个按钮。下一个故事板 - 名为 "st2" 的 viewController 有一个 tableView。
当我从 st1 转到 st2 时,出现以下错误。
我正在使用尺寸 class 和自动布局。
2015-01-18 13:10:40.199 myApp[1108:35975] 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:0x7fa1f1d2a310 V:[UITextField:0x7fa1f1d283c0(30)]>",
"<NSLayoutConstraint:0x7fa1f1d30780 UITextField:0x7fa1f1d283c0.top == UITableViewCellContentView:0x7fa1f1d271a0.topMargin>",
"<NSLayoutConstraint:0x7fa1f1d30870 UITableViewCellContentView:0x7fa1f1d271a0.bottomMargin == UITextField:0x7fa1f1d283c0.bottom - 3>",
"<NSLayoutConstraint:0x7fa1f1d64d00 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fa1f1d271a0(43.5)]>"
)
Will attempt to recover by breaking constraint
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.
显示此错误5次。我只是把它删掉了,这样会更容易阅读。
如你所知,我是初学者,所以请不要对我太苛刻。
它看起来像是在抱怨,因为你已经将文本字段的高度限制为 30(即第一个约束中的'(30)'),但你还希望文本字段的顶部位于上边距它的单元格和单元格底部边缘的底部 -3 单元格的高度为 43.5。因此,您同时要求文本字段的高度为 30 和 40.5 - 这是冲突。
限制文本字段的顶部和底部并且不设置高度
或
设置高度但不设置底部约束
或
调整单元格的高度(可能不是最佳方案)
我有 2 个故事板。第一个 - 名为 "st1" 的 tableViewController 具有带有 5 个标签的静态单元格、5 个文本字段和 2 个按钮。下一个故事板 - 名为 "st2" 的 viewController 有一个 tableView。
当我从 st1 转到 st2 时,出现以下错误。
我正在使用尺寸 class 和自动布局。
2015-01-18 13:10:40.199 myApp[1108:35975] 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:0x7fa1f1d2a310 V:[UITextField:0x7fa1f1d283c0(30)]>",
"<NSLayoutConstraint:0x7fa1f1d30780 UITextField:0x7fa1f1d283c0.top == UITableViewCellContentView:0x7fa1f1d271a0.topMargin>",
"<NSLayoutConstraint:0x7fa1f1d30870 UITableViewCellContentView:0x7fa1f1d271a0.bottomMargin == UITextField:0x7fa1f1d283c0.bottom - 3>",
"<NSLayoutConstraint:0x7fa1f1d64d00 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fa1f1d271a0(43.5)]>"
)
Will attempt to recover by breaking constraint
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.
显示此错误5次。我只是把它删掉了,这样会更容易阅读。
如你所知,我是初学者,所以请不要对我太苛刻。
它看起来像是在抱怨,因为你已经将文本字段的高度限制为 30(即第一个约束中的'(30)'),但你还希望文本字段的顶部位于上边距它的单元格和单元格底部边缘的底部 -3 单元格的高度为 43.5。因此,您同时要求文本字段的高度为 30 和 40.5 - 这是冲突。
限制文本字段的顶部和底部并且不设置高度
或
设置高度但不设置底部约束
或
调整单元格的高度(可能不是最佳方案)