Xcode 日志显示约束错误,但 Storyboard 文件中没有错误

Xcode logs showing constraint errors, however there're no errors in Storyboard file

这很令人惊讶,我不确定,但是我的 Xcode 的调试日志向我展示了一些随机约束错误,但是 Storyboard 文件中没有错误(并且没有影响在我的应用程序中的任何位置)。

我发布这个问题只是为了确保存在一些严重的问题或我身边遗漏了什么?

这是我的日志:

2016-02-04 17:46:17.432 MyApp[3586:198217] 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. 
(
    "<NSLayoutConstraint:0x7fe19aeebd00 V:[UIButton:0x7fe19aeedee0(44)]>",
    "<NSLayoutConstraint:0x7fe19aef0cf0 V:[UIButton:0x7fe19aeedee0]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19aeed8e0 )>",
    "<NSLayoutConstraint:0x7fe19aef0d40 V:|-(0)-[UIButton:0x7fe19aeedee0]   (Names: '|':UITableViewCellContentView:0x7fe19aeed8e0 )>",
    "<NSLayoutConstraint:0x7fe19d007580 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19aeed8e0(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe19aeebd00 V:[UIButton:0x7fe19aeedee0(44)]>

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.
2016-02-04 17:46:17.434 MyApp[3586:198217] 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. 
(
    "<NSLayoutConstraint:0x7fe19d0124a0 V:[UIButton:0x7fe19d0121f0(44)]>",
    "<NSLayoutConstraint:0x7fe19d014420 V:[UIButton:0x7fe19d0121f0]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19d012060 )>",
    "<NSLayoutConstraint:0x7fe19d014470 V:|-(0)-[UIButton:0x7fe19d0121f0]   (Names: '|':UITableViewCellContentView:0x7fe19d012060 )>",
    "<NSLayoutConstraint:0x7fe19d00bb90 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19d012060(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe19d0124a0 V:[UIButton:0x7fe19d0121f0(44)]>

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.
2016-02-04 17:46:17.435 MyApp[3586:198217] 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. 
(
    "<NSLayoutConstraint:0x7fe19d019820 V:[UIButton:0x7fe19d019570(44)]>",
    "<NSLayoutConstraint:0x7fe19d01b7a0 V:[UIButton:0x7fe19d019570]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19d0193e0 )>",
    "<NSLayoutConstraint:0x7fe19d01b7f0 V:|-(0)-[UIButton:0x7fe19d019570]   (Names: '|':UITableViewCellContentView:0x7fe19d0193e0 )>",
    "<NSLayoutConstraint:0x7fe19d01f130 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19d0193e0(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe19d019820 V:[UIButton:0x7fe19d019570(44)]>

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.
2016-02-04 17:46:17.436 MyApp[3586:198217] 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. 
(
    "<NSLayoutConstraint:0x7fe19d020640 V:[UIButton:0x7fe19d020390(44)]>",
    "<NSLayoutConstraint:0x7fe19d022460 V:[UIButton:0x7fe19d020390]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19d020200 )>",
    "<NSLayoutConstraint:0x7fe19d0224b0 V:|-(0)-[UIButton:0x7fe19d020390]   (Names: '|':UITableViewCellContentView:0x7fe19d020200 )>",
    "<NSLayoutConstraint:0x7fe19ac90e20 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19d020200(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe19d020640 V:[UIButton:0x7fe19d020390(44)]>

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.
2016-02-04 17:46:17.438 MyApp[3586:198217] 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. 
(
    "<NSLayoutConstraint:0x7fe19d027410 V:[UIButton:0x7fe19d027160(44)]>",
    "<NSLayoutConstraint:0x7fe19d029390 V:[UIButton:0x7fe19d027160]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19d026fd0 )>",
    "<NSLayoutConstraint:0x7fe19d0293e0 V:|-(0)-[UIButton:0x7fe19d027160]   (Names: '|':UITableViewCellContentView:0x7fe19d026fd0 )>",
    "<NSLayoutConstraint:0x7fe19ac7da90 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19d026fd0(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe19d027410 V:[UIButton:0x7fe19d027160(44)]>

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.
2016-02-04 17:46:17.439 MyApp[3586:198217] 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. 
(
    "<NSLayoutConstraint:0x7fe19d02e2c0 V:[UIButton:0x7fe19d02e010(44)]>",
    "<NSLayoutConstraint:0x7fe19d030240 V:[UIButton:0x7fe19d02e010]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19d02de80 )>",
    "<NSLayoutConstraint:0x7fe19d030290 V:|-(0)-[UIButton:0x7fe19d02e010]   (Names: '|':UITableViewCellContentView:0x7fe19d02de80 )>",
    "<NSLayoutConstraint:0x7fe19af28d90 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19d02de80(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe19d02e2c0 V:[UIButton:0x7fe19d02e010(44)]>

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.

这是我的故事板视图列表:

配置:

Xcode v.7.1.1

iOS v.9.1.

您似乎在使用自定义 table 视图单元格。您是否检查了单元格的 .xib 文件的约束?

编辑: 看起来单元格的按钮高度有问题。检查您是否同时设置了按钮的高度以及顶部和底部约束。如果是,那就是导致问题的原因。

要解决此问题,请移除按钮的高度约束或顶部或底部约束。

你给的限制在某处被打破了。这就是它显示错误的原因。因此,确定您不需要的约束并删除它们。 (例如,重复约束或没有任何意义的约束,例如您提供前导和尾随以及固定宽度。)

"UIView-Encapsulated-Layout-Height"约束是布局引擎默认设置的。您收到的错误意味着您为单元格设置的高度与系统认为应该的高度冲突。

一个有效的选项是降低约束的优先级。这将解决冲突。如果它也能生成所需的布局,那很好。您打算使用不同高度的单元格吗?

"<NSLayoutConstraint:0x7fe19d027410 V:[UIButton:0x7fe19d027160(44)]>",

"<NSLayoutConstraint:0x7fe19d029390 V:[UIButton:0x7fe19d027160]-(-1)-|   (Names: '|':UITableViewCellContentView:0x7fe19d026fd0 )>",

"<NSLayoutConstraint:0x7fe19d0293e0 V:|-(0)-[UIButton:0x7fe19d027160]   (Names: '|':UITableViewCellContentView:0x7fe19d026fd0 )>",

"<NSLayoutConstraint:0x7fe19ac7da90 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fe19d026fd0(44)]>"


button.height = 44.

button.bottom = contentView.bottom+1

button.top = contentView.top;

contentView.height = 44

.

当所有按钮一起出现时,高度应为 45。但您明确将其设置为 44。 删除按钮的高度限制,或者,使 button.bottom = contentView.bottom.