将图像检索到我的 UIImageView

Posted

技术标签:

【中文标题】将图像检索到我的 UIImageView【英文标题】:Retrieving an image to my UIImageView 【发布时间】:2016-09-30 22:44:28 【问题描述】:

我使用我的 android 应用程序 Parse 在我的数据库中加载图像,我想在我的 iphone 上显示它。

当我运行 Xcode 时告诉我:'Could not release the value of type' NSConcreteData 'to' PFFile ''

有什么方法可以获取此图像并在我的 iPhone (UIImageView) 上显示??

有什么可以帮助我的吗?

不胜感激!!

enter image description here

【问题讨论】:

问题是,你的对象["profile picture"] 是 NSData 而不是 PFFile 哥们这是怎么回事?人们正在投入时间试图帮助你,所以至少回答 对不起,我没有我的 mac,完全忘记了。我今天成功了 我只是使用了"let getParseImg NSData = [" image "] as!NSData" 并且没有使用函数"getDataInBackgroundWithBlock" 好的。但是请关闭问题,这样人们就不会浪费时间思考您的问题。很高兴你成功了 【参考方案1】:

问题在于,正如编译器告诉你的那样,你正试图将 NSData 转换为 PFFile。

只需使用:

    let userImageProfilePicture = event["profile_picture"]
    userImageProfilePicture.getDataInBackgroundWithBlock( (data, error) -> Void in

          // handle here with your userAuth == true block

          if let data = data where error == nil
              var image = UIImage(data: data)
          
    )

【讨论】:

很抱歉延迟回答你,我没有我的 MAC 我现在测试了你的代码,但我也得到了 let getParseImg NSData = [" image "] as! NSData,不使用函数“getDataInBackgroundWithBlock” 好的,但是由于我的回答也对您有用,您可以接受我的回答还是我说的对? :)

以上是关于将图像检索到我的 UIImageView的主要内容,如果未能解决你的问题,请参考以下文章