Ios 无法同时满足自定义标题节的约束

Ios 无法同时满足自定义标题节的约束,ios,swift,uitableview,autolayout,Ios,Swift,Uitableview,Autolayout,对于表视图,我的自定义标题部分有一个.nib: 自定义标题部分可以工作,但每当我插入新部分时,控制台上就会显示一条警告: 2017-10-02 14:56:32.791529+0800 Project[1017:14993] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is

对于表视图,我的自定义标题部分有一个.nib:

自定义标题部分可以工作,但每当我插入新部分时,控制台上就会显示一条警告:

2017-10-02 14:56:32.791529+0800 Project[1017:14993] [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. 
(
    "<NSLayoutConstraint:0x61000009f8b0 UIButton:0x7ff359d0d4a0.width == 22   (active)>",
    "<NSLayoutConstraint:0x61000009f900 UITextField:0x7ff359d19660.width == UILabel:0x7ff359d17650'$0.00'.width   (active)>",
    "<NSLayoutConstraint:0x61000009fa90 UITextField:0x7ff359d19660.leading == UIView:0x7ff359d010a0.leadingMargin   (active)>",
    "<NSLayoutConstraint:0x61000009ed20 H:[UITextField:0x7ff359d19660]-(30)-[UILabel:0x7ff359d17650'$0.00']   (active)>",
    "<NSLayoutConstraint:0x61000009f2c0 UIButton:0x7ff359d0d4a0.trailing == UIView:0x7ff359d010a0.trailingMargin   (active)>",
    "<NSLayoutConstraint:0x61000009ee60 H:[UILabel:0x7ff359d17650'$0.00']-(7)-[UIButton:0x7ff359d0d4a0]   (active)>",
    "<NSLayoutConstraint:0x61000009f5e0 H:[UIView:0x7ff359d010a0]-(0)-|   (active, names: '|':Project.BillTableSection:0x7ff359d0fc70 )>",
    "<NSLayoutConstraint:0x61000009f9a0 H:|-(0)-[UIView:0x7ff359d010a0]   (active, names: '|':Project.BillTableSection:0x7ff359d0fc70 )>",
    "<NSLayoutConstraint:0x61000009ff40 '_UITemporaryLayoutWidth' Project.BillTableSection:0x7ff359d0fc70.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x61000009f8b0 UIButton:0x7ff359d0d4a0.width == 22   (active)>

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.
2017-10-02 14:56:32.791529+0800项目[1017:14993][LayoutConstraints]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(
"",
"",
"",
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。

我试图找到不需要的约束并删除它们,但我定义的布局在其他设备上不再适用。忽略此警告是否安全?我不知道如何调试这个。。。请帮忙

您应该将
BtnAdd.training
优先级降低到1000以下。看起来autolayout添加了一个临时约束

这会压扁所有内容,因此删除绝对优先级将使您的内容调整时不会发生冲突



另外,为什么
TxtName.width
=
LblPrice.width
?您不能调整内容包含优先级吗?

您应该将
BtnAdd.training
优先级降低到1000以下。看起来autolayout添加了一个临时约束

这会压扁所有内容,因此删除绝对优先级将使您的内容调整时不会发生冲突



另外,为什么
TxtName.width
=
LblPrice.width
?您不能调整内容包含优先级吗?

尝试将“添加项目宽度约束”按钮的
优先级设置为999,然后查看是否仍显示警告。@Amit我刚刚将其设置为999。不幸的是,警告仍然显示…请尝试将“添加项目宽度约束”按钮的
优先级设置为999,然后查看是否仍然显示警告。@Amit我刚刚将其设置为999。不幸的是,警告仍然显示…谢谢!它起作用了。。。我想做一个文本字段,当你编辑时,自动调整宽度,但是中间也留一些空间,以便在点击时结束编辑,但是我不确定如何正确地设置它。这实际上是聪明的。我想你想让标签填充剩余的宽度。此外,人们通常不知道如何使用拥抱优先级和抗压性,但您的解决方案听起来不错。谢谢!它起作用了。。。我想做一个文本字段,当你编辑时,自动调整宽度,但是中间也留一些空间,以便在点击时结束编辑,但是我不确定如何正确地设置它。这实际上是聪明的。我想你想让标签填充剩余的宽度。此外,人们通常不知道如何使用拥抱优先权和压缩阻力,但您的解决方案听起来不错。
2017-10-02 14:56:32.791529+0800 Project[1017:14993] [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. 
(
    "<NSLayoutConstraint:0x61000009f8b0 UIButton:0x7ff359d0d4a0.width == 22   (active)>",
    "<NSLayoutConstraint:0x61000009f900 UITextField:0x7ff359d19660.width == UILabel:0x7ff359d17650'$0.00'.width   (active)>",
    "<NSLayoutConstraint:0x61000009fa90 UITextField:0x7ff359d19660.leading == UIView:0x7ff359d010a0.leadingMargin   (active)>",
    "<NSLayoutConstraint:0x61000009ed20 H:[UITextField:0x7ff359d19660]-(30)-[UILabel:0x7ff359d17650'$0.00']   (active)>",
    "<NSLayoutConstraint:0x61000009f2c0 UIButton:0x7ff359d0d4a0.trailing == UIView:0x7ff359d010a0.trailingMargin   (active)>",
    "<NSLayoutConstraint:0x61000009ee60 H:[UILabel:0x7ff359d17650'$0.00']-(7)-[UIButton:0x7ff359d0d4a0]   (active)>",
    "<NSLayoutConstraint:0x61000009f5e0 H:[UIView:0x7ff359d010a0]-(0)-|   (active, names: '|':Project.BillTableSection:0x7ff359d0fc70 )>",
    "<NSLayoutConstraint:0x61000009f9a0 H:|-(0)-[UIView:0x7ff359d010a0]   (active, names: '|':Project.BillTableSection:0x7ff359d0fc70 )>",
    "<NSLayoutConstraint:0x61000009ff40 '_UITemporaryLayoutWidth' Project.BillTableSection:0x7ff359d0fc70.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x61000009f8b0 UIButton:0x7ff359d0d4a0.width == 22   (active)>

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.