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)
(
"<MASLayoutConstraint:0x7fafcb1c8e10 UIButton:0x7fafcb18e160.width == UIView:0x7fafcb0bd380.width - 60>",
"<NSAutoresizingMaskLayoutConstraint:0x7fafcb0a2570 UIView:0x7fafcb0bd380.width == 0>"
)
Will attempt to recover by breaking constraint
<MASLayoutConstraint:0x7fafcb1c8e10 UIButton:0x7fafcb18e160.width == UIView:0x7fafcb0bd380.width - 60>
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.
在手撸约束的时间,经常会碰到类似的约束警告,其实对布局显示是没有影响的,但是看到这个警告真是蛋疼的要死啊,整个人的心情都不好了,怎么办?谷歌、百度啊。
结果如下:
当你决定在你的项目中大规模使用AutoLayout时,那么NSAutoresizingMaskLayoutConstraint大部分情况下是非常不和谐的东西,它通常会把你的程序搞崩溃,幸好IB中的View不会出现这个问题,如果你使用代码添加了view并且出现了NSAutoresizingMaskLayoutConstraint相关的问题,你应该将该View的translatesAutoresizingMaskIntoConstraints设置为NO。
再次编辑,又遇到了这个扯淡的问题,按照上面的方法,可以消除警告,但是现实的宽度不对了。
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px}span.s1 {font-variant-ligatures: no-common-ligatures}span.Apple-tab-span {white-space:pre}
**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:0x7fdfc403ec90 MeHeadView:0x7fdfc4069730.trailing == UILabel:0x7fdfc40900d0.trailing + 20>",**
** "<NSLayoutConstraint:0x7fdfc40a8210 UILabel:0x7fdfc40900d0.leading == MeHeadView:0x7fdfc4069730.leading + 20>",**
** "<NSLayoutConstraint:0x7fdfc1d6c250 MeHeadView:0x7fdfc4069730.width == 0>"**
**)**
****
**Will attempt to recover by breaking constraint **
**<NSLayoutConstraint:0x7fdfc403ec90 MeHeadView:0x7fdfc4069730.trailing == UILabel:0x7fdfc40900d0.trailing + 20>**
****
**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.**
先修改如下
Paste_Image.png把其中一个关于superview的约束从Required修改为High,就可以了;既消除了警告,也不影响视图的现实,但是我不知道是为什么!!!!!
2018/03/20
断断续续的还有人看到这个文章,后续在写一点吧。
出现这样的警告一般是因为视图的约束条件之间有冲突,譬如:视图有两个约束条件,一个是条件A要求视图的宽度大于 200,另一个条件B要求视图的宽度小于等于他的父视图,如果不设置优先级,当父视图的宽度小于 200 时,A 条件和B条件之间就发生了冲突,系统不知道采用那个约束条件的情况下就会产生警告。而修改了优先级以后,会告诉系统,如果条件之间有冲突,优先满足优先级高的那个条件。
网友评论
虽然我还是不知道为什么要这样做,但是毫无疑问它拯救了我这样的强迫症患者.
如果能知道这样改的原因是什么就好了,难道又是苹果扔出来的一枚bug?