How do I disable the full swipe on a tableview cell in iOS11

Implement like below :

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let delete = UIContextualAction(style: .destructive, title: "Delete") { (action, sourceView, completionHandler) in
        print("index path of delete: \(indexPath)")
        completionHandler(true)
    }
    let swipeAction = UISwipeActionsConfiguration(actions: [delete])
    swipeAction.performsFirstActionWithFullSwipe = false // This is the line which disables full swipe
    return swipeAction
}

This is the line which disables full swipe

swipeAction.performsFirstActionWithFullSwipe = false 

And remove the other functions if you implement any like editingStyle and editActionsForRowAt.


I was able to disable swipe actions for particular cells by following this answer: https://stackoverflow.com/a/50597672/1072262

Instead of returning nil you can return:

return UISwipeActionsConfiguration.init()