代码写作中碰到了这样一个情况,block回调时,控制台打印了这样的信息。
This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
Stack:(
0 Foundation 0x0000000181fdc424 <redacted> + 96
1 Foundation 0x0000000181dd6ad4 <redacted> + 76
2 Foundation 0x0000000181dd69e8 <redacted> + 120
3 Foundation 0x0000000181dd6794 <redacted> + 112
4 UIKit 0x000000018b0969d0 <redacted> + 2152
5 QuartzCore 0x000000018560be54 <redacted> + 184
6 QuartzCore 0x000000018560ffe4 <redacted> + 324
7 QuartzCore 0x000000018557c6c8 <redacted> + 320
8 QuartzCore 0x00000001855a41b0 <redacted> + 580
9 QuartzCore 0x00000001855a5030 <redacted> + 92
10 CoreFoundation 0x000000018142a910 <redacted> + 32
11 CoreFoundation 0x0000000181428238 <redacted> + 412
12 CoreFoundation 0x0000000181348dc8 CFRunLoopRunSpecific + 584
13 WebCore 0x000000018960c2d4 <redacted> + 592
14 libsystem_pthread.dylib 0x00000001810a9220 <redacted> + 272
15 libsystem_pthread.dylib 0x00000001810a9110 <redacted> + 0
16 libsystem_pthread.dylib 0x00000001810a7b10 thread_start + 4
)
查看之后,发现是由于线程操作不当导致的,在子线程中执行了 popViewControllerAnimated: 操作,
修改为
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.navigationController popViewControllerAnimated:YES];
});
重新调试之后,没有再出现上述打印信息