iOS如何从表视图单元格Swift中解析图像

时间:2018-04-13 11:49:49

标签: ios swift parse-platform

我使用一个项目,我需要在表格视图单元格中显示图像,我在解析数据库中。 我加载文字的代码:

   override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! cellRequestsTVC
    let good = data[indexPath.row]
    name = good["username"] as! String
    cell.userNameLable.text = "Name: \(name)"
    area = good["place"] as! String
    cell.areaLable.text = "Area: \(area)"
    cell.descriptionLable.text = good["description"] as? String
    cell.priorityLable.setRoundEdge()
cell.dataLable.text = good["openData"] as! String

    return cell
}

我有一个变量:

var data = [PFObject]()

如何在单元格中加载图片,使用解析?

1 个答案:

答案 0 :(得分:1)

在您的PFFile方法中获取此类背景中的let avatar = good["image"] as! PFFile avatar.getDataInBackground{ (imageData, error)in if imageData != nil { let image = UIImage(data: imageData!) cell.Image.image = image } else { print(error) } } 数据。

{{1}}
相关问题