Я хочу щелкнуть ячейку и вызвать действие редактирования. Но я не уверен, как реализовать вызов смахивания вручную. Я думаю, что в этом ответе есть решение, но я не совсем понимаю цель C. https://stackoverflow.com/a/29839673/5737856
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// swipe
//tableView(tableView, editActionsForRowAtIndexPath: indexPath) or other functions???
}
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: " Edit " , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
print("EDIT")
})
editAction.backgroundColor = UIColor.blueColor()
let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
print("DELETE")
})
return [deleteAction, editAction]
}