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 


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.

在手撸约束的时间,经常会碰到类似的约束警告,其实对布局显示是没有影响的,但是看到这个警告真是蛋疼的要死啊,整个人的心情都不好了,怎么办?谷歌、百度啊。

结果如下:

当你决定在你的项目中大规模使用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,就可以了;既消除了警告,也不影响视图的现实,但是我不知道是为什么!!!!!


2018/03/20
断断续续的还有人看到这个文章,后续在写一点吧。

出现这样的警告一般是因为视图的约束条件之间有冲突,譬如:视图有两个约束条件,一个是条件A要求视图的宽度大于 200,另一个条件B要求视图的宽度小于等于他的父视图,如果不设置优先级,当父视图的宽度小于 200 时,A 条件和B条件之间就发生了冲突,系统不知道采用那个约束条件的情况下就会产生警告。而修改了优先级以后,会告诉系统,如果条件之间有冲突,优先满足优先级高的那个条件。

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