I would like to know if there is an option to close the editing menu in the table view (as shown in the screenshot) which we get when we swipe to right. I want the menu to close as soon i select an option, in my case it does not close even when i select any one of the option. It closes only when i select anywhere on the screen.
Below is my code which im using
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
}
func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -> Bool {
return true
}
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
{
let update = UITableViewRowAction(style: .Normal, title: "Update") { action, index in
print("update")
}
let delete = UITableViewRowAction(style: .Default, title: "Delete") { action, index in
print("Delete")
}
return [delete, update]
}
You need to just reload the particular cell and it's close the option.
For that you can use following code may this solve your problem.
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top)
Also you can use
self.tableView.setEditing(false, animated: true)
Happy coding.
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