如何解决:此应用程序正在从后台线程修改自动布局引擎 [英] How to solve: This application is modifying the autolayout engine from a background thread

查看:58
本文介绍了如何解决:此应用程序正在从后台线程修改自动布局引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当代码的某些部分从主线程以外的其他线程更改UI项时,会将此错误记录到控制台.但是我怎么找到它在哪里呢?

This error is logged to the console when some part of the code is changing UI items from other threads than the main thread. But how can I find where it does this?

推荐答案

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

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.

这篇关于如何解决:此应用程序正在从后台线程修改自动布局引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆