Aldo Lazuardi Aldo Lazuardi - 2 months ago 62
Swift Question

how to automatically slide/swipe the cell tableviewcell swift 3

how to automatically slide the cell when we touch button like adding contact? is there any delegate for that?

when we clicked the delete button, cell automatically slide

Answer

You should implement delegate method - commitEditingStyle and you will be done!!

something like,

   func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
{

    // below code will delete one row - you can mange another kind of deletion here like delete from database also
    if editingStyle == .Delete
    {
        yourDataArray.removeAtIndex(indexPath.row)
        self.yourTableView.reloadData()
    }
}

And you can do on button's click,

   self.yourTableView.setEditing(true, animated: true)

to show (-) sign on every cells !