使用 UIViewAlertForUnsatisfiableConstraints 捕捉autolayout 约束冲突

很多时候我们会遇到约束冲突的问题、但是因为苹果只会在log中提示冲突、且这些冲突很难去理解、所以遇到冲突、也很难发现到底是哪里出了问题、但是苹果还是提供了方法、去debug的。
我们来看冲突的log:

2015-08-26 14:29:32.870 Auto Layout Cookbook[10208:1918826] 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) 
(
    "",
    "=400)]>",
    "",
    "",
    ""
)

Will attempt to recover by breaking constraint
0x7b56d020 'Label Width' H:[UILabel:0x7b58b040'Name'(>=400)]>

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.

里面写了

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

这就意味着、我们可以通过symbolic breakpoint 来捕捉冲突、如何来设定呢?平时管理断点的地方、点击加号、addMake a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.然后在symbol内容填上UIViewAlertForUnsatisfiableConstraints、如果出现冲突、系统会自动停留在断点处、还是蛮好用的。
使用 UIViewAlertForUnsatisfiableConstraints 捕捉autolayout 约束冲突_第1张图片

使用 UIViewAlertForUnsatisfiableConstraints 捕捉autolayout 约束冲突_第2张图片
更多断点知识、可以参考cocoa的文章只会左键断点?是时候试试这样那样断点了

你可能感兴趣的:(iOS,苹果,调试,布局,autolayout)