gpt4 book ai didi

ios - 收到以下错误 : This application is modifying the autolayout engine from a background thread

转载 作者:行者123 更新时间:2023-11-29 11:58:38 27 4
gpt4 key购买 nike

我收到此代码的警告。如果有可用更新,我正在后台检查。然后发出警报。显然 Xcode 和 iOS 不喜欢我的想法……有什么想法吗?

  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {

if CheckAppUpdate().appUpdateAvailable("http://itunes.apple.com/lookup?id=xxxxxxxxxxxxx") == true {

self.showAlertForUpdate()
}
})

最佳答案

在 iOS 中,所有 UI 代码必须在主线程上运行。您正在分派(dispatch)到后台线程以执行更新检查,这很好,但随后尝试从同一后台线程更新 UI,这会导致您看到的错误。解决方案是在第一个中添加另一个 dispatch_async,包装对 self.showAlertForUpdate() 的调用,但分派(dispatch)到主队列 (dispatch_get_main_queue(.. .) 而不是。

关于ios - 收到以下错误 : This application is modifying the autolayout engine from a background thread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38040810/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com