这是我的代码:为什么UITableView commitEditing不起作用?
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if (editingStyle == UITableViewCellEditingStyle.Delete) {
print("1")
let deleteAction = UITableViewRowAction(style: .Normal, title: "Delete") { (rowAction: UITableViewRowAction, indexPath:NSIndexPath) -> Void in
print("clicking1")
if let selfiePublicID = self.selfiePublicID {
print("clicking2")
let URL = "\(self.properties.host)\(self.properties.addComment)\(selfiePublicID)/action/2"
print(URL)
self.userParameters.profileParameters["value"] = self.comments[indexPath.row].commentText
Alamofire.request(.DELETE, URL, parameters: self.userParameters.profileParameters, encoding: .JSON).validate().responseJSON { response in
do {
let json = JSON(data: response.data!)
print(json)
self.comments.removeAtIndex(indexPath.row)
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
}
}
}
deleteAction.backgroundColor = UIColor.redColor()
}
}
它的工作,但现在没有,我不知道为什么。在日志中我得到1
,但后来我没有得到clicking1
和clicking2
。
那里有什么问题?