我使用GCD在iPhone应用程序中生成了很多缩略图。我有看起来像这样的东西:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // generate thumbnail

    // store thumbnail

    dispatch_async(dispatch_get_main_queue(), ^{
        // display thumbnail (cellForRowAtIndexPath and cell.imageView.image = ..
    });
);

它运行良好,但是我想降低显示屏的优先级,以便具有更响应的UI线程。

有帮助吗?

解决方案

主队列(与主线程关联)没有优先级。您不能更改其优先级。

无论如何,您可能会发布 NSNotification 使用 NSPostWhenIdle 发布样式。仅当您的应用程序有一些空闲时间时,才能执行您的代码。看 在文档 /专用编程指南中 关于这样的技术。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top