How to use Swipe Method with TableView editing

24 Views Asked by At

I am using leadingSwipeActionsConfigurationForRowAt method for Swipe. I also using drag and drop feature here.

Property tableview.editing is true in this condition. then i can't get callback of swipe.

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

}
1

There are 1 best solutions below

0
Ely On

You must return an UISwipeActionsConfiguration object, like this example:

override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        
    let firstAction = UIContextualAction(style: .normal, title: "First Action", handler: { (action, view, done) in
        // Do stuff here
        done(true) // completion handler
    })
       
    let secondAction = UIContextualAction(style: .normal, title: "Second Action", handler: { (action, view, done) in
        // Do stuff here
        done(true) // completion handler
    })
        
    let config = UISwipeActionsConfiguration(actions: [firstAction, secondAction])
    config.performsFirstActionWithFullSwipe = true       
    return config
}