如何快速解析加载图像

如何快速解析加载图像

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

问题描述

限时删除!!

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

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"从哪里来?解析确实说过在这里,我们从另一个名为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:48