0

我目前正在使用 AFNetworking 的自定义UIImageView+AFNetworking.h从 URLS 下载两个图像,如下所示:

[self.topPicture setImageWithURL:upperPicture];
[self.bottomPicture setImageWithURL:lowerPicture];

大约 20% 的时间可以正常工作,尽管其余时间我收到以下错误:

<Error>: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedImageBlockData: readSession [0x8a4ebd0] has bad readRef [0x8a50f30]

我不确定这是因为我试图同时将两个图像设置到屏幕上(以及在主线程上),还是因为我没有正确配置 AFNetworking。

更新:

我正在使用 Parse API 的查询功能使用代码获取用户的个人资料图片

NSArray *foundMatches = [queryForMatches findObjects]; //each "match" is a NSDictionary

其中查询也在主线程上运行。稍后,我使用类似于

matchedUser[@"user_picture"] //user_picture is a string, which I then set to a new NSURL withString

在将它传递给setImageWithURL:函数之前。至少从我所见,一切都在主线程上检索。

更新 2:

我尝试只使用 下载一张图片getImageWithURL,这工作正常,我没有收到上述错误。

4

1 回答 1

0

这两行代码是在后台线程中执行的吗?

根据苹果的文档

注意:在大多数情况下,UIKit 类只能在应用程序的主线程中使用。对于从 UIResponder 派生的类或涉及以任何方式操作应用程序的用户界面的类尤其如此。

于 2013-08-27T21:06:26.250 回答