小编典典

如何捕获 UIViewAlertForUnsatisfiableConstraints?

all

我看到调试器日志中出现错误:

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x191f0920 H:[MPKnockoutButton:0x17a876b0]-(34)-[MPDetailSlider:0x17a8bc50](LTR)>

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.

我该如何打那个电话?它没有出现在我的代码中的任何地方。

截图1


阅读 102

收藏
2022-05-04

共1个答案

小编典典

这篇文章对我帮助 很大

我添加了带有建议操作的 UIViewAlertForUnsatisfiableConstraints 符号断点:

Obj-C 项目

po [[UIWindow keyWindow] _autolayoutTrace]

Objective-C
项目中具有自定义操作的符号断点

斯威夫特项目

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

带有自定义操作的符号断点

有了这个提示,日志变得更加详细,我更容易确定哪个视图的约束被破坏了。

UIWindow:0x7f88a8e4a4a0
|   UILayoutContainerView:0x7f88a8f23b70
|   |   UINavigationTransitionView:0x7f88a8ca1970
|   |   |   UIViewControllerWrapperView:0x7f88a8f2aab0
2022-05-04