iosswiftuitableviewuiswipeactionsconfiguration

Dismiss UISwipeActionsConfiguration on reloading the table


When user swipe the cell I m showing some option. Everything is working fine, When user scroll the table swipe option goes off. I want the same behaviour when I reload the table on data change. How to achieve that. If user has swipe the cell and I reload table , Swipe options are still there.


Solution

  • You hide the swiped cell just add this line of code before reloading the table view.

    tableView.setEditing(false, animated: true)
    

    Now for enabling the editing, In your cellForAtIndex Path function make a check like

    if indexPath.row == array.size {
       tableView.setEditing(true, animated: true)
    }