Can I force confirmation of swiping to delete?

I’d like to show several buttons (including Delete) when the user swipes left in a UITableView. However, at least one tester has been too exuberant, and did a long swipe which deletes without confirmation. They were surprised and unhappy.


Is there a way to prevent that long swipe from doing anything other than exposing the buttons?


(I know this is changed behavior, on iOS 9 for iPad 2, you cannot do the long swipe. I believe in my app, safety should prevail over convenience, and the original behavior makes more sense.)

Accepted Reply

Apparently, you have to manually implement the delete button by using UITableViewDelegate.tableView(_:trailingSwipeActionsConfigurationForRowAt:) and setting the UISwipeActionsConfiguration.performsFirstActionWithFullSwipe = false


See the last code example at the bottom of this StackOverflow post: https://stackoverflow.com/a/47068781

Replies

Apparently, you have to manually implement the delete button by using UITableViewDelegate.tableView(_:trailingSwipeActionsConfigurationForRowAt:) and setting the UISwipeActionsConfiguration.performsFirstActionWithFullSwipe = false


See the last code example at the bottom of this StackOverflow post: https://stackoverflow.com/a/47068781

Ah, I guess I have to implement both that and -tableView:editActionsForRowAtIndexPath: (apparently that is used on iOS 11 of you have an edit mode).