Error about updating UI in background thread

Error about updating UI in background thread,第1张

How to fix the following error "bool _WebTryThreadLock(bool), 0xxxxxx: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now..."?

Cause: update ui in background thread.

Solution: update ui in main thread.

Generic use:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        // Do time-consuming task in background thread
	// Return back to main thread to update UI
        dispatch_sync(dispatch_get_main_queue(), ^{
            // Update UI
        });
    });

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/2090315.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-07-22
下一篇 2022-07-22

发表评论

登录后才能评论

评论列表(0条)

保存