在手表套件异步下载表格中的图像 [英] Download images in a Table in watch kit async
问题描述
我正在开发一个 WatchKit
应用程序,我需要一些图像(有时是 50 个缩略图)来完成一个 Table
.我正在 iOS
应用程序中下载图像并将它们传递给 WatchKit 扩展
,但我遇到了问题.
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
,所有元素都带有 image
和 label代码>.主要问题是当我下载这些图像并按下一项以查看其详细信息时,
直到所有图像都下载完毕.主线程
被阻止并且应用程序不会将 push
发送到 push
code>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 图片提示 帖子.
这篇关于在手表套件异步下载表格中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!