【发布时间】:2020-01-29 07:16:18
【问题描述】:
即使我的 UI 在
上更新,我也会收到此错误DispatchQueue.main.async {
}
我试图找出导致此警告的原因并冻结了应用程序。我附上屏幕截图以获取更多详细信息。任何人都可以帮助解决这个问题吗?我尝试查看此Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] Freezes the application 和此Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState],但没有帮助。
【问题讨论】:
-
代码是必需的
-
如果您单击左侧菜单中的运行时问题,它将显示导致主线程检查器警告的代码。这行代码应该在主线程上调用。对我来说,这是从后台线程调用的 UIViewController 初始化。一旦我将它放入
DispatchQueue.main.async { }块中,它就消失了。 -
@Chiara 是的,我检查了没有调度就什么都没有
-
你能把代码贴在块里吗?
-
我没有使用任何导致此错误的东西。如何共享代码块
标签: ios swift multithreading grand-central-dispatch