gpt4 book ai didi

ios - QoS 用户交互和更新 UI

转载 作者:行者123 更新时间:2023-11-28 19:37:30 25 4
gpt4 key购买 nike

在 iOS 上,UI 应该只通过主线程更新,但令我感兴趣的是在文档中,用户交互服务质量是这样定义的:

Work that is interacting with the user, such as operating on the main thread, refreshing the user interface, or performing animations. If the work doesn’t happen quickly, the user interface may appear frozen. Focuses on responsiveness and performance.

问题是,如果您使用该 QoS 调用 dispatch_get_global_queue,返回的队列将不是主队列,对吗?因此,提交到该队列的工作如何刷新 UI?

谢谢。

最佳答案

Dispatch_get_global_queue 总会给你全局并发队列。您不能像在主队列之外的任何队列中那样更新该队列中的用户界面。

与用户交互 Qos 一样,它用于对 ui 至关重要的工作,并且需要尽快获得结果。

一个很好的例子是您有一张需要处理的图像。您可以使用用户交互 Qos 处理 global_queue 中的图像,完成后将结果图像设置在 imageView 中(这是在主队列中完成的)。

关于ios - QoS 用户交互和更新 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37424003/

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