作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到此代码的警告。如果有可用更新,我正在后台检查。然后发出警报。显然 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/
我是一名优秀的程序员,十分优秀!