【发布时间】:2015-12-03 13:23:37
【问题描述】:
我真的很难尝试从 Parse 加载图像...我已经设置好它通过 JavaScript 将图像作为文件发送到 Parse(见屏幕截图),现在我试图在 Swift 2.1/Xcode 7.2 Beta 中将图像加载到我的 UIImageView 中。没有错误返回,应用程序的其余部分按预期运行。不过,我似乎无法让它工作。任何帮助将不胜感激。
let currentUser = PFUser.currentUser()
if currentUser != nil {
if let companyImage = currentUser!["pic"] as? PFFile {
companyImage.getDataInBackgroundWithBlock({ ( imageData: NSData?, error: NSError?) -> Void in
if error == nil{
self.pic.image = UIImage(data: imageData!)
} else {
print("No image found")
}
})
}
编辑:
我还在我的应用程序中编辑了 Info.plist 文件,以确保可以处理向 Internet 发出的请求,并且它工作正常,因为我能够加载用户的用户名。
【问题讨论】:
-
用文件填充其余行。您可能会收到一个错误,因为其他两行是空的,所以它不返回任何内容。
标签: ios swift parse-platform swift2 swift2.1