且构网

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

Xcode7:此应用程序正在从后台线程修改自动布局引擎,这可能导致引擎损坏和奇怪的崩溃

更新时间:2022-12-09 10:47:54

我不知道您的代码是什么,但是我对为什么会这样有一个想法.您必须在后台线程中进行一些UI更改.

I don't know what your code is, but I have an idea as to why this is happening. You must be having some UI changes done in a background thread.

请勿从主线程以外的任何内容更改UI,它必须绑定到 使您的应用程序不稳定,并意外崩溃.

Do not change UI from anything but the main thread, it is bound to make your application unstable, and crash unpredictably.

使用GCD(大中间派遣).

您可以从任何线程侦听和执行工作,并将UI更改封装在dispatch_async中:

Use GCD (Grand Central Dispatch).

You can listen and do work from any thread, and encapsulate UI changes in a dispatch_async:

dispatch_async(dispatch_get_main_queue(), ^{
        // Do UI stuff here
});