Dismiss UISwipeActionsConfiguration by swiping back

Great question!

This is not a direct configuration, but if you also implement an action for leading in addition to your existing trailing:

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let action = UIContextualAction(style: .normal, title: "bla") { (action, view, success) in
        success(true)
    }
    return UISwipeActionsConfiguration(actions: [action])
}

This will give you the desired effect.

Unfortunately, this requires an action for swiping right. I tried making the actions array [], but that doesn't do anything.


let delete = UIContextualAction(style: .destructive, title: "Delete") { (myContext, myView, complete) in

//Did what you wanted to do
complete(true)

//Cancelled the action
complete(false)

}