[iOS] 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.

遇到程式掛掉,發出的錯誤訊息:

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.


聽說可以用解法:

Swift 3

 DispatchQueue.main.async {
    // Update UI
 }

Swift Version < 3

dispatch_async(dispatch_get_main_queue(){
    // code here
})

Objective-C Version

dispatch_async(dispatch_get_main_queue(), ^{
    // code here
});

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *