Disable the full swipe on a tableview cell in iOS 11

1 min read Sep 25, 2017

Disable the full swipe on a tableview cell in iOS 11

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
}

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

Picsew | Ezra