主线程检查器:在后台线程上调用的UI API:-[UIApplication委托]冻结应用程序 [英] Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] Freezes the application

查看:80
本文介绍了主线程检查器:在后台线程上调用的UI API:-[UIApplication委托]冻结应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我的应用程序从JSON获取数据时,有时都会收到此警告,并且应用程序立即冻结:

Whenever my application fetch data from JSON it sometimes get this warning and application freezes right away:

主线程检查器:在后台线程上调用的UI API:-[UIApplication委托]

Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]

PID:7439,TID:362794,线程名称:(无),队列名称:NSOperationQueue 0x60000002f7c0(QOS:未审查),QoS:0 回溯:

PID: 7439, TID: 362794, Thread name: (none), Queue name: NSOperationQueue 0x60000002f7c0 (QOS: UNSPECIFIED), QoS: 0 Backtrace:

任何人都可以解释如何摆脱它吗?

Can anyone explain how to get rid of it?

推荐答案

您似乎正在从不是主线程的线程更新UI上的某些内容.

It looks like you're updating something on the UI from a thread that's not the main thread.

您的问题没什么要继续的了.但是,如果您使用的是JSON,则可能是异步检索它.确保无论何时从检索到的内容更新UI时,都应通过

There's not a lot to go on in your question. But if you're using JSON, you're probably retrieving it asynchronously. Make sure that whenever you update the UI from something retrieved, that you wrap it up in a call to the main thread through something like

dispatch_async(dispatch_get_main_queue(), ^{
// code to post to UI
});

这篇关于主线程检查器:在后台线程上调用的UI API:-[UIApplication委托]冻结应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆