[LayoutConstraints] Unable to simultaneously satisfy constraints.

问题描述:

[LayoutConstraints] Unable to simultaneously satisfy constraints.不能同时地满足约束

图1 约束可能存在问题的控件

解决方法:

1. Will attempt to recover by breaking constraint 


通过改变 UIImageView:0x7fc857b60980的height来满足约束,这里我们可以到对应设置约束的界面,找到可能约束有问题的UIImageView,查看约束是否有问题,并且改之。我一般都是通过这种方式来解决问题的。

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

使用symbolic breakpoint来抓取不合适约束

第一步

在Symbol后的输入框处填入UIViewAlertForUnsatisfiableConstraints标志

图二 添加符号断点

第二步  在action里面添加调试命令

Obj-C project

po [[UIWindow keyWindow] _autolayoutTrace]

Swift project

expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]

图三 编辑符号断点

第三步 xcode控制台会打印出详细的约束信息,在控制台搜索AMBIGUOUS,含有AMBIGUOUS的约束都可能有问题。

这种方法看上去挺专业的,说实话效率不是很高,推荐使用第一种方法。

3.The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

这种方法还未试过,以后试过后添加上来。

你可能感兴趣的:([LayoutConstraints] Unable to simultaneously satisfy constraints.)