且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决:此应用程序正在从后台线程修改自动布局引擎

更新时间:2022-12-09 10:57:19

此应用程序正在从后台线程修改自动布局引擎"的主要问题是,似乎在实际问题发生很长时间后就记录下来了,这可能很难排除故障.

Main problem with "This application is modifying the autolayout engine from a background thread" is that it seem to be logged a long time after the actual problem occurs, this can make it very hard to troubleshoot.

我设法通过创建三个符号断点来解决该问题.

I managed to solve the issue by creating three symbolic breakpoints.

调试>断点>创建符号断点...

Debug > Breakpoints > Create Symbolic Breakpoint...

断点1:

  • 符号:-[UIView setNeedsLayout]

条件:!(BOOL)[NSThread isMainThread]

断点2:

  • 符号:-[UIView layoutIfNeeded]

条件:!(BOOL)[NSThread isMainThread]

断点3:

  • 符号:-[UIView updateConstraintsIfNeeded]

条件:!(BOOL)[NSThread isMainThread]

有了这些断点,您可以轻松地在错误地调用非主线程上的UI方法的实际行上中断.

With these breakpoints, you can easily get a break on the actual line where you incorrectly call UI methods on non-main thread.