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

2024-04-08

当我更新 Xcode7 时,我收到了此消息。能告诉我解决办法吗?感谢。

该应用程序正在从后台线程修改自动布局引擎,这可能会导致引擎损坏和奇怪的崩溃。这将在未来的版本中导致异常。

Stack:(
    0   CoreFoundation                      0x250df883 <redacted> + 150
    1   libobjc.A.dylib                     0x367dedff objc_exception_throw + 38
    2   CoreFoundation                      0x250df7b1 <redacted> + 0
    3   Foundation                          0x25f7be63 <redacted> + 170
    4   Foundation                          0x25e21ba7 <redacted> + 38
    5   UIKit                               0x292f3aa9 <redacted> + 52
    6   UIKit                               0x292f4487 <redacted> + 222
    7   UIKit                               0x299ccfa5 <redacted> + 288
    8   UIKit                               0x294e5fa9 <redacted> + 148
    9   UIKit                               0x291ed6bb <redacted> + 694
    10  QuartzCore                          0x28ab967d <redacted> + 128
    11  QuartzCore                          0x28ab4d79 <redacted> + 352
    12  QuartzCore                          0x28ab4c09 <redacted> + 16
    13  QuartzCore                          0x28ab4129 <redacted> + 368
    14  QuartzCore                          0x28ab3deb <redacted> + 590
    15  WebCore                             0x34a9c79f <redacted> + 282
    16  CoreFoundation                      0x250a2827 <redacted> + 14
    17  CoreFoundation                      0x250a2417 <redacted> + 454
    18  CoreFoundation                      0x250a077f <redacted> + 806
    19  CoreFoundation                      0x24ff31e9 CFRunLoopRunSpecific + 516
    20  CoreFoundation                      0x24ff2fdd CFRunLoopRunInMode + 108
    21  WebCore                             0x34040cdf <redacted> + 422
    22  libsystem_pthread.dylib             0x37077c93 <redacted> + 138
    23  libsystem_pthread.dylib             0x37077c07 _pthread_start + 110
    24  libsystem_pthread.dylib             0x37075a24 thread_start + 8
)

我不知道你的代码是什么,但我知道为什么会发生这种情况。您必须在后台线程中完成一些 UI 更改。

除了主线程之外,不要更改 UI,它必然会 使您的应用程序不稳定并意外崩溃。

使用 GCD(中央调度)。

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

dispatch_async(dispatch_get_main_queue(), ^{
        // Do UI stuff here
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐