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.關于這個問題網上有好多,但是解決辦法好像給的并不明確。告訴我該在回到主線程的時候刷新UI,然而我并不知道這個問題出現的地方在哪里,也不知道哪里需要回到主線程后刷新UI。
首先下載PSPDFUIKitMainThreadGuard(它本身就只有一個.m,你沒有搞錯!)
接著在PSPDFAssertIfNotMainThread方法上打個斷點
60AF00CE-9D7D-4A28-84D2-DDAC5C81CA91.png
-
報錯后你就可以找到錯誤根源了
F10B43E3-1631-4FBB-AAD1-776C85F6A1A5.png 最后,就可以把該放進GCD執行的代碼放進去就OK了!
dispatch_async(dispatch_get_main_queue(), ^{
// Some UIKit call that had timing issues but works fine
// in the next runloop.
[self updateUI];
});