iOS9 - 此应用程序正在从后台线程修改autolayout引擎 - 在哪里? [英] iOS9 - This application is modifying the autolayout engine from a background thread -- where?

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

问题描述

对于搜索,错误消息是:

For searching, the error message is:


此应用程序正在从后台线程修改autolayout引擎,这可能会导致引擎腐败和奇怪的崩溃。这将在将来的版本中引发异常。

This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.

我知道这意味着从后台线程调用了一些UIKit代码,我知道解决方案是将代码包装在

I know this means some UIKit code is called from a background thread, and I know the solution is to wrap the code in

dispatch_async(dispatch_get_main_queue(),^(void){< code>});

我的问题是找到这样做的地方,因为没有任何打印的堆栈跟踪引用我的应用程序代码。我证明这是否定的证据是在调试输出窗口中搜索(命令-f)我的应用程序的名称;我有24个堆栈跟踪被丢弃,我的应用程序名称不在其中任何一个,除了顶部有错误消息。我可以发布其中一个,但这似乎没有用。

My problem is locating where to do that, as none of the printed stack traces reference my app code. My evidence to prove this negative is searching (command-f) in the debug output window for the name of my app; I have 24 stack traces dumped out and my app name is not in any of them, except at the top with the error message. I can post one of them, but that doesn't seem very useful.

在我今天工作的情况下,这是在转换视图控制器后发生的,在 viewWillDisappear()之前viewWillAppear()。我已经找到了部分代码来包装 dispatch_async(),但这些都是现在处理的。我有断点和调试消息,其中分配和取消分配与视图控制器相关的对象,并且它们都在异常消息出现后触发。在调试和发布模式下,模拟器和我的iOS9 iPhone都会发生这种情况。

In the cases I am working on today, this is happening when transitioning view controllers, after viewWillDisappear() and before viewWillAppear(). I have found parts of my code to wrap dispatch_async() around, but those are all handled now. I have breakpoints and debug messages where objects relevant to the view controllers are allocated and deallocated, and they all trigger after the exception messages appear. This is happening both on the simulator and my iOS9 iPhone, both in debug and release modes.

如何识别显然修改UI的后台代码?

How can I identify the background code which is apparently modifying the UI?

推荐答案

此代码 PSPDFUIKitMainThreadGuard 导致主线程外的UIKit访问断言

This code PSPDFUIKitMainThreadGuard causes assertions on UIKit access outside the main thread

使用步骤:


  1. 添加到项目并编译此文件而不使用ARC

  2. PSPDFAssert 定义移至文件的第一个

  3. 评论调用 PSPDFLogError ,因为它未定义

  4. import < UIKit / UIKit.h>

  1. Add to project and compile this file without ARC
  2. Move PSPDFAssert definition to the first of the file
  3. Comment calling of PSPDFLogError as it is not defined
  4. import <UIKit/UIKit.h>

您的应用程序将崩溃并停止任何尝试修改任何UI元素从后台线程

Your app will crash and stop with any attemption to modify any UI element from background thread

有关迅速使用以下代码: NBUIKitMai nThreadGuard

For swift use the following code: NBUIKitMainThreadGuard

这篇关于iOS9 - 此应用程序正在从后台线程修改autolayout引擎 - 在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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