【问题标题】:[UIImageAsset retain]: message sent to deallocated instance[UIImageAsset 保留]:发送到已释放实例的消息
【发布时间】:2015-02-16 14:57:33
【问题描述】:

一行

UIImage *tempImage = [UIImage imageNamed:@"gradient-image"];

在后台线程的 NSOperation 中执行。 代码在此处中断并显示消息:

[UIImageAsset retain]: message sent to deallocated instance

我在Images.xcassets 中有名称为gradient-image 的图像。 老实说,我什至不知道还有什么其他信息是相关的。

这种情况很少发生,我无法始终如一地重现它。 我用谷歌搜索了一下,但没有多少结果。所以,我决定在这里创建一个关于 SO 的问题。

【问题讨论】:

    标签: ios ios8 uiimageasset


    【解决方案1】:

    直接从Apple's documentationUIImage imageNamed:

    你不能假设这个方法是线程安全的。

    加载UIImage 对象时,您必须在主线程上。使用它们时可以在任何线程上,但加载它们需要主线程。

    【讨论】:

      猜你喜欢
      • 2014-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-23
      • 2011-07-15
      相关资源
      最近更新 更多