本文介绍了如何快速从解析加载图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想知道是否有人可以帮助我,我是应用程序开发的新手我正在从我的应用程序上传图像进行解析,在解析文档的帮助下没有问题.

I was wondering if anyone can help me, I'm new to app developingI am uploading images from my app to parse with no problem with help from parse documentation.

    let imageData = UIImagePNGRepresentation(scaledImage)
    let imageFile: PFFile = PFFile(data: imageData)

    var userPhoto = PFObject(className: "postString")
    userPhoto["imageFile"] = imageFile
    userPhoto.saveInBackground()

但是当我添加代码来检索图像时,我有点迷茫:/

but when i add the code to retrieve the image back, I'm a bit lost :/

let userImageFile = anotherPhoto["imageFile"] as PFFile
userImageFile.getDataInBackgroundWithBlock {
(imageData: NSData!, error: NSError!) -> Void in
  if !error {
     let image = UIImage(data:imageData)
   }
}

anotherPhoto"从何而来?Parse 确实说这里我们从另一个名为 anotherPhoto 的 UserPhoto 中检索图像文件:"

where is the "anotherPhoto" coming from ? Parse did say "Here we retrieve the image file off another UserPhoto named anotherPhoto:"

推荐答案

anotherPhoto 将是您的 postString(userPhoto 在您的上传示例).适合您的文件下载示例如下:

anotherPhoto would be an instance of your postString (userPhoto in your upload example). The file downloading example that would work for you is like this:

let userImageFile = userPhoto["imageFile"] as PFFile
userImageFile.getDataInBackgroundWithBlock {
    (imageData: NSData!, error: NSError!) -> Void in
    if !error {
        let image = UIImage(data:imageData)
    }
}

任何 PFFile 都必须从普通 PFObject 中引用,否则无法检索.PFFile 对象本身不会显示在数据浏览器中.

Any PFFile must be referenced from a normal PFObject or it cannot be retrieved. PFFile objects themselves will not show up in the data browser.

这篇关于如何快速从解析加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:47