ios 约束冲突NSAutoresizingMaskLayoutConstraint

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) 
(
    "",
    ""
)

Will attempt to recover by breaking constraint 
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) **
**(**
**    "",**
**    "",**
**    ""**
**)**
****
**Will attempt to recover by breaking constraint **
****
****
**Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.**
**The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in  may also be helpful.**

先修改如下

ios 约束冲突NSAutoresizingMaskLayoutConstraint_第1张图片
Paste_Image.png

把其中一个关于superview的约束从Required修改为High,就可以了;既消除了警告,也不影响视图的现实。

你可能感兴趣的:(ios 约束冲突NSAutoresizingMaskLayoutConstraint)