9

Is there any way to programmatically trigger the equivalent of swiping left on a UITableViewCell that has edit actions? This is different from simply [tableView setEditing:YES animated:YES] as that method sets the entire table into editing mode and shows the insert/delete left accessory view and/or reorder controls rather than the edit actions for a single row.

Ken M. Haggerty
  • 24,902
  • 5
  • 28
  • 37

1 Answers1

-2

You can use optional func tableView(_ tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle from UITableViewDelegate. And return UITableViewCellEditingStyleDelete for the cell you want to swipe. Use func reloadRowsAtIndexPaths(_ indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) to reload that cell when you want to trigger the swipe.

Jelly
  • 4,522
  • 6
  • 26
  • 42