【发布时间】:2015-10-31 18:49:39
【问题描述】:
我正在尝试从 Parse 检索用户个人资料图片(文件)到我的 PFQueryTableViewController。我相信我已经正确地编写了我的代码,但我可能做错了什么。那么如何从解析中检索用户图像以显示在我的查询中?
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?, object: PFObject!) -> PFTableViewCell? {
let cell = tableView!.dequeueReusableCellWithIdentifier("TCell", forIndexPath: indexPath!) as! Tweets
if let userTweet : PFObject = self.tweets.objectAtIndex(indexPath!.row) as! PFObject {
cell.username.text = object["account"] as? String
cell.post.text = object["post"] as? String
cell.post.numberOfLines = 0
if let Pic = object["photo"] as? PFFile {
cell.userImage.image = UIImage(named: "Image")
cell.userImage.file = Pic
}
}
【问题讨论】:
-
出了什么问题?您是否调试并检查了
userImage是否存在? -
我在 'cell.userImage.file= pic' 得到一个错误,说 UIImageView 的值没有成员 'file'
-
UIImageView 没有实现
file。您可能期望您的单元格的图像视图是PFImageView,它隐藏了获取文件内容、将这些内容解释为图像并将其 imageView(可能是它的超类)图像设置为结果的工作。跨度>
标签: swift parse-platform pfquery