iOS - 如何修复AutoLayout的破坏约束?

时间:2017-10-11 06:39:55

标签: ios autolayout constraints

我正在使用AutoLayout来配置我的iOS应用的视图。

一切顺利,但我最近遇到了一些问题。

在日志屏幕上打印了大量脏警告警报,应用程序变得非常缓慢。

但是成功编译完成并且屏幕配置为我想要的。

以下日志是“过多的脏警告提醒”的一部分,但与我的核心问题无关。所以可以忽略这一点。

[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:0x170280f00 UIView:0x10296ee30.width == UIView:0x102971940.width   (active)>",
    "<NSLayoutConstraint:0x170281040 H:|-(0)-[UIView:0x102971940]   (active, names: '|':Common.TopFilterView:0x102b2d9b0 )>",
    "<NSLayoutConstraint:0x170281090 H:[UIView:0x102971940]-(0)-|   (active, names: '|':Common.TopFilterView:0x102b2d9b0 )>",
    "<NSLayoutConstraint:0x170281310 Common.TopFilterView:0x102b2d9b0.trailing == UIView:0x102971ae0.trailing - 8   (active)>",
    "<NSLayoutConstraint:0x170281360 H:|-(8)-[Common.TopFilterView:0x102b2d9b0]   (active, names: '|':UIView:0x102971ae0 )>",
    "<NSLayoutConstraint:0x170280ff0 H:|-(0)-[UIView:0x102971ae0]   (active, names: '|':dealer.CarAuctionHeaderView:0x10296ded0 )>",
    "<NSLayoutConstraint:0x1702810e0 H:[UIView:0x102971ae0]-(0)-|   (active, names: '|':dealer.CarAuctionHeaderView:0x10296ded0 )>",
    "<NSLayoutConstraint:0x170282e40 '_UITemporaryLayoutWidth' dealer.CarAuctionHeaderView:0x10296ded0.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x170280f00 UIView:0x10296ee30.width == UIView:0x102971940.width   (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-11 11:52:35.171573 dealer[633:151926] [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:0x170281310 Common.TopFilterView:0x102b2d9b0.trailing == UIView:0x102971ae0.trailing - 8   (active)>",
    "<NSLayoutConstraint:0x170281360 H:|-(8)-[Common.TopFilterView:0x102b2d9b0]   (active, names: '|':UIView:0x102971ae0 )>",
    "<NSLayoutConstraint:0x170280ff0 H:|-(0)-[UIView:0x102971ae0]   (active, names: '|':dealer.CarAuctionHeaderView:0x10296ded0 )>",
    "<NSLayoutConstraint:0x1702810e0 H:[UIView:0x102971ae0]-(0)-|   (active, names: '|':dealer.CarAuctionHeaderView:0x10296ded0 )>",
    "<NSLayoutConstraint:0x170282e40 '_UITemporaryLayoutWidth' dealer.CarAuctionHeaderView:0x10296ded0.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x170281310 Common.TopFilterView:0x102b2d9b0.trailing == UIView:0x102971ae0.trailing - 8   (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-11 11:52:35.172660 dealer[633:151926] [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:0x174098970 Common.TopFilterView:0x102b2d9b0.height == 24   (active)>",
    "<NSLayoutConstraint:0x17009fe50 Common.AuctionBoardView:0x10296e650.height == 32   (active)>",
    "<NSLayoutConstraint:0x170281270 V:|-(0)-[Common.AuctionBoardView:0x10296e650]   (active, names: '|':UIView:0x102971ae0 )>",
    "<NSLayoutConstraint:0x1702811d0 Common.TopFilterView:0x102b2d9b0.bottom == UIView:0x102971ae0.bottom - 8   (active)>",
    "<NSLayoutConstraint:0x1702813b0 V:[Common.AuctionBoardView:0x10296e650]-(18)-[Common.TopFilterView:0x102b2d9b0]   (active)>",
    "<NSLayoutConstraint:0x170281540 V:|-(0)-[UIView:0x102971ae0]   (active, names: '|':dealer.CarAuctionHeaderView:0x10296ded0 )>",
    "<NSLayoutConstraint:0x170281590 V:[UIView:0x102971ae0]-(0)-|   (active, names: '|':dealer.CarAuctionHeaderView:0x10296ded0 )>",
    "<NSLayoutConstraint:0x170283fc0 '_UITemporaryLayoutHeight' dealer.CarAuctionHeaderView:0x10296ded0.height == 0   (active)>"
)

并非所有这些都是我能理解的错误,但我通过各种方法解决了这些错误。

然而,仍然存在一种我真的无法理解的错误。

[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:0x170490900 V:|-(0)-[Common.RippleView:0x10a2d3600]   (active, names: '|':Common.DetailProgressView:0x10a2f2ac0'\Uc131\Ub2a5\Uc810\Uac80\Uae30\Ub85d\Ubd80' )>",
    "<NSLayoutConstraint:0x17068d890 V:[Common.RippleView:0x10a2d3600]-(0)-|   (active, names: '|':Common.DetailProgressView:0x10a2f2ac0'\Uc131\Ub2a5\Uc810\Uac80\Uae30\Ub85d\Ubd80' )>",
    "<NSLayoutConstraint:0x170681ae0 'UISV-canvas-connection' UIStackView:0x10b745ee0.top == Common.DetailProgressView:0x10b7460a0'\Uac80\Ucc28\Uacb0\Uacfc'.top   (active)>",
    "<NSLayoutConstraint:0x170681b80 'UISV-canvas-connection' V:[Common.DetailProgressView:0x10a2d9840'\Uc774\Uc804\Ub4f1\Ub85d\Uc99d']-(0)-|   (active, names: '|':UIStackView:0x10b745ee0 )>",
    "<NSLayoutConstraint:0x170681ea0 'UISV-hiding' UIStackView:0x10b745ee0.height == 0   (active)>",
    "<NSLayoutConstraint:0x170681c20 'UISV-spacing' V:[Common.DetailProgressView:0x10b7460a0'\Uac80\Ucc28\Uacb0\Uacfc']-(8)-[Common.DetailProgressView:0x10a2f2ac0'\Uc131\Ub2a5\Uc810\Uac80\Uae30\Ub85d\Ubd80']   (active)>",
    "<NSLayoutConstraint:0x1706817c0 'UISV-spacing' V:[Common.DetailProgressView:0x10a2f2ac0'\Uc131\Ub2a5\Uc810\Uac80\Uae30\Ub85d\Ubd80']-(8)-[Common.DetailProgressView:0x10a2d9840'\Uc774\Uc804\Ub4f1\Ub85d\Uc99d']   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x17068d890 V:[Common.RippleView:0x10a2d3600]-(0)-|   (active, names: '|':Common.DetailProgressView:0x10a2f2ac0'성능점검기록부' )>

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-11 15:31:54.657816 dealer[306:22643] [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:0x170681ae0 'UISV-canvas-connection' UIStackView:0x10b745ee0.top == Common.DetailProgressView:0x10b7460a0'\Uac80\Ucc28\Uacb0\Uacfc'.top   (active)>",
    "<NSLayoutConstraint:0x170681b80 'UISV-canvas-connection' V:[Common.DetailProgressView:0x10a2d9840'\Uc774\Uc804\Ub4f1\Ub85d\Uc99d']-(0)-|   (active, names: '|':UIStackView:0x10b745ee0 )>",
    "<NSLayoutConstraint:0x170681ea0 'UISV-hiding' UIStackView:0x10b745ee0.height == 0   (active)>",
    "<NSLayoutConstraint:0x170681c20 'UISV-spacing' V:[Common.DetailProgressView:0x10b7460a0'\Uac80\Ucc28\Uacb0\Uacfc']-(8)-[Common.DetailProgressView:0x10a2f2ac0'\Uc131\Ub2a5\Uc810\Uac80\Uae30\Ub85d\Ubd80']   (active)>",
    "<NSLayoutConstraint:0x1706817c0 'UISV-spacing' V:[Common.DetailProgressView:0x10a2f2ac0'\Uc131\Ub2a5\Uc810\Uac80\Uae30\Ub85d\Ubd80']-(8)-[Common.DetailProgressView:0x10a2d9840'\Uc774\Uc804\Ub4f1\Ub85d\Uc99d']   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1706817c0 'UISV-spacing' V:[Common.DetailProgressView:0x10a2f2ac0'성능점검기록부']-(8)-[Common.DetailProgressView:0x10a2d9840'이전등록증']   (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-11 15:31:54.658671 dealer[306:22643] [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:0x17069b8a0 'UISV-canvas-connection' UIStackView:0x10a0cdf70.top == Common.HDLabel:0x102dc5340'\Uacac\Uc801\Uc774 \Ub192\Uc740 \Uc21c\Uc73c\Ub85c \Uc815\Ub82c\Ub429\Ub2c8\Ub2e4.'.top   (active)>",
    "<NSLayoutConstraint:0x17069b9e0 'UISV-canvas-connection' V:[Common.ReceivedEstimateView:0x10a0a8220]-(0)-|   (active, names: '|':UIStackView:0x10a0cdf70 )>",
    "<NSLayoutConstraint:0x174499f50 'UISV-hiding' UIStackView:0x10a0cdf70.height == 0   (active)>",
    "<NSLayoutConstraint:0x17069bc60 'UISV-spacing' V:[Common.HDLabel:0x102dc5340'\Uacac\Uc801\Uc774 \Ub192\Uc740 \Uc21c\Uc73c\Ub85c \Uc815\Ub82c\Ub429\Ub2c8\Ub2e4.']-(8)-[Common.ReceivedEstimateView:0x10a0a8220]   (active)>"
)

我怀疑这些与隐藏的UIStackView的间距有关。

因为所有有问题的视图都在隐藏的UIStackView中。它们之间唯一存在的是UIStackView的间距。

但我无法使用AutoLayout调整UIStackView的间距。 (也许每个人都是。不是吗?)

所以我不知道如何解决这个问题。我想知道这个问题的原因和解决方案。

感谢。

0 个答案:

没有答案