【发布时间】:2015-04-14 06:10:35
【问题描述】:
我正在使用 PFQueryTableViewController 并将其设置为仅查找此用户已批准或发送给他的友谊。
“fromUser”和“toUser”是指向用户类的指针,我需要查询结果中包含的每个用户的用户名和profilePicture。
现在我尝试在我的 cellForRowAtIndexPath 方法中获取它们并加载图像:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
let cellIdentifier = "contactCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as! PFTableViewCell
if let user = object?["fromUser"] as? PFUser {
user.fetchInBackgroundWithBlock({ (user, error) -> Void in
if error != nil {
println("Could not fetch user object")
}
let user = user as! PFUser
cell.textLabel?.text = user.username!
cell.imageView?.file = user["profilePicture"] as? PFFile
cell.imageView?.loadInBackground()
})
} }
让用户名显示在 tableView 中工作正常,但实际上从未加载图像。我尝试了不同的方法来加载图像,但我的单元格的 imageView 属性始终为零。
- 原型的类设置为 PFTableViewCell
- 控制器链接到情节提要中的视图
如果你们知道为什么这个内置属性是 nil 以及如何解决这个问题,请告诉我。
谢谢,
【问题讨论】:
标签: swift parse-platform parseui