Search code examples
iosswiftuitableviewuikitswipe

UITableViewDelegate method for swipe actions is not called at iOS 13


I use a tableView(_:trailingSwipeActionsConfigurationForRowAt:) method in order to add swipe-to-delete gesture in iOS app. It works as expected at iOS 16.2 simulator. But in iOS 13.7 simulator it does not show any actions on swipe.

The method is:

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { [weak self] action, view, handler in
            self?.presenter.requestDeletion(at: indexPath.row)
        }
        
        let config = UISwipeActionsConfiguration(actions: [deleteAction])
        return config
    }

I've set breakpoints inside the method and they are not even called on swipe. Swipes at iOS 16.2 trigger the breakpoints.


Solution

  • It's necessary to return true from the tableView(_:canEditRowAt:) data source method, and swipe actions work as expected.