gpt4 book ai didi

ios - Swift:线程中的 URLRequest

转载 作者:行者123 更新时间:2023-11-28 07:53:21 27 4
gpt4 key购买 nike

我想从 url 获取数据,但在过程完成之前,我想显示加载图标

我使用此代码但不适合我

DispatchQueue.global(qos: .background).async {
// show loading icon
// start get data
DispatchQueue.main.async {
// remove loading icon
}
}

最佳答案

来自 UIView

Threading Considerations

Manipulations to your application’s user interface must occur on themain thread. Thus, you should always call the methods of the UIViewclass from code running in the main thread of your application. Theonly time this may not be strictly necessary is when creating the viewobject itself but all other manipulations should occur on the mainthread.

这意味着您可能应该在主线程中显示/隐藏和操作您的 View ,而不是像在“显示加载 View ”中那样在后台线程中进行操作。

关于ios - Swift:线程中的 URLRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49081637/

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