I've implemented tableView:editActionsForRowAtIndexPath:
. In response to some of these actions, i want to snap the row action area back closed.
There doesn't seem to be an appropriate method on UITableViewRowAction
. I've tried endEditing
on both the table and table cell; I'm not sure what to try next.
How do I do snap the action area closed?
If you do self.tableView.setEditing(false, animated: true)
, the user will be brought out of editing mode. I think what you want is you want to stay in editing mode but just dismissing the row action. So you can use the following code:
self.tableView.cellForRow(at: cellIndex)?.setEditing(false, animated: true)
self.tableView.reloadData() // this is necessary, otherwise, it won't animate
To close the edit actions you can either set the tableViews edit state:
tableView.editing = NO
or set it with animation:
[tableView setEditing:NO animated:YES]
Update for Swift 3
I've been looking for a way to do this using Swift 3, and I finally found it:
tableView.isEditing = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With