I have a custom UITableViewRowAction set up and working. The only thing I can't work out is how to dismiss the UITableViewRowAction once an action has been selected. I'm sure I'm missing something really obvious. Here is my current setup:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? { var moreRowAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "In", handler:{action, indexpath in //Some code to execute here }); moreRowAction.backgroundColor = UIColor(red: 0.298, green: 0.851, blue: 0.3922, alpha: 1.0) return [moreRowAction]; }
Thanks for any advice.
You dismiss the action in the handler which gets called when the action is tapped. The documentation describes the handler as follows
The block to execute when the user taps the button associated with this action. UIKit makes a copy of the block you provide. When the user selects the action represented by this object, UIKit executes your handler block on the app’s main thread.
Independently, I suppose you could just set the table views editing
property to false.
tableView.setEditing(false, animated: true)
This works for me:
tableView.editing = NO;
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