【发布时间】:2015-03-06 12:25:01
【问题描述】:
您好,我希望获得一个自定义单元配件类型来在图像之间进行更改。现在它是一个复选标记,然后没有复选标记。我使用 Parse 作为我的后端,每个用户都有关注者并且关注多个人。我想将其更改为在两个图像之一之间显示以供关注或+关注。现在它已设置为复选标记。我当前的代码在我的下面有没有人有任何建议?
覆盖 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var cell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
if cell.accessoryType == UITableViewCellAccessoryType.Checkmark {
cell.accessoryType = UITableViewCellAccessoryType.None
var query = PFQuery(className:"followers")
query.whereKey("follower", equalTo:PFUser.currentUser().username)
query.whereKey("following", equalTo:cell.textLabel?.text)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
for object in objects {
object.delete()
}
} else {
// Log details of the failure
println(error)
}
}
} else {
cell.accessoryType = UITableViewCellAccessoryType.Checkmark
var following = PFObject(className: "followers")
following["following"] = cell.textLabel?.text
following["follower"] = PFUser.currentUser().username
following.save()
}
}
【问题讨论】:
标签: ios parsing swift custom-cell tableviewcell