Я изо всех сил пытаюсь получить изображение, сохраненное в Parse, чтобы отобразить его в моем UITableViewCell
. Ячейка заполняется из других данных, хранящихся в объекте Parse (имя и т. Д.) - только изображение отображается неправильно.Parse Image -> UITableViewCell Not Displaying (Swift)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
if let client: PFObject = self.clientList[indexPath.row] as? PFObject {
let forename: String = client["forename"] as! String
let surname: String = client["surname"] as! String
let fullname: String = forename + " " + surname
cell.textLabel?.text = fullname
cell.detailTextLabel?.text = client.objectId
let userImageFile = client["image"] as? PFFile
if let imageFile = userImageFile {
println(imageFile)
imageFile.getDataInBackgroundWithBlock({ (imageData: NSData?, error: NSError?) -> Void in
if error == nil {
if let imageData = imageData {
self.image = UIImage(data: imageData)!
}
}
})
// THIS DOESN'T DISPLAY AN IMAGE WHEN RUN
cell.imageView?.image = image
} else {
// THIS IS A LOCAL IMAGE DISPLAYED IF THE PARSE OBJECT DOESN'T CONTAIN AN IMAGE FILE. THIS DOES DISPLAY CORRECTLY WHEN CALLED.
let image = UIImage(named: "userMale")
cell.imageView?.image = image
println("Local Image")
}
}
cell.imageView?.layer.cornerRadius = 40
cell.imageView?.layer.masksToBounds = true
cell.imageView?.layer.borderColor = UIColor.lightGrayColor().CGColor
cell.imageView?.layer.borderWidth = 1
return cell
}
Вы пробовали println (self. изображение) после утверждения - self.image = UIImage (data: imageData)! или прямо перед тем, как попытаться установить изображение в ячейку? –