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

时间:2016-02-04 12:20:05

标签: ios xcode nslayoutconstraint

这是一个惊喜,我不确定,但是我的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.

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

enter image description here

配置:

Xcode v.7.1.1

iOS v.9.1。

4 个答案:

答案 0 :(得分:4)

你给出的限制在某个地方破坏了。这就是它出现错误的原因。因此,请确定您不需要的约束并将其删除。 (例如,重复约束或没有任何意义的约束,例如您给出前导和尾随以及固定宽度。)

答案 1 :(得分:2)

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

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

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

答案 2 :(得分:1)

&#34; UIView-Encapsulated-Layout-Height&#34;约束是默认情况下由布局引擎设置的约束。您获得的错误意味着您为单元格设置的高度与系统认为的高度冲突。

有效选项是降低约束的优先级。这将解决冲突。如果它也产生了所需的布局,那你就是好的。你是否打算拥有不同高度的细胞?

答案 3 :(得分:0)

"<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