在手表套件异步下载表中的图像 [英] Download images in a Table in watch kit async

查看:66
本文介绍了在手表套件异步下载表中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发WatchKit应用,我需要获取一些图像(有时是50张缩略图)以实现Table.我正在iOS应用程序中下载图像并将它们传递给WatchKit Extension,但是我遇到了问题.

I am developing a WatchKit app, I need to get some images(sometimes 50 thumbnails) to fulfill a Table. I am downloading the images in the iOS app and passing them to the WatchKit Extension, but I am having problems.

首先,我有三个按钮,如果按其中一个按钮,则会看到带有某些元素的Table,所有元素均带有imagelabel.主要问题是,当我下载这些图像时,我按一个项目以查看其详细信息,main thread被阻止,并且在下载所有图像之前,应用程序不会将push更改为DetailsController.

First, I have three buttons, if I press one of them I see a Table with some elements, all of them with image and label. The main problem is when I am downloading those images and I press one item to see its detail, the main thread is blocked and the app doesn't make push to the DetailsController until all the images are downloaded.

有人处理过包含许多元素和图像的表格吗?您如何解决这个问题?

Has anyone dealt with a Table with many elements and images?? How do you solved this?

谢谢

推荐答案

在后台线程上缓存图像是安全的,因此从WatchKit扩展中将其分发到后台队列,并使用WKInterfaceDevice及其addImage样式的方法.然后,在实际更新接口之前,请确保分派回主队列.

It is safe to cache images on a background thread, so from your WatchKit extension, dispatch to a background queue, and use WKInterfaceDevice and one of its addImage-style methods. Then, be sure to dispatch back to the main queue before you actually update the interface.

我会在 WatchKit图像提示中详细介绍其中的一些技术帖子.

I cover some of these techniques in more detail in my WatchKit Image Tips post.

这篇关于在手表套件异步下载表中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆