Aldo Lazuardi
Aldo Lazuardi

Reputation: 1948

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

Upvotes: 4

Views: 2278

Answers (1)

Ketan Parmar
Ketan Parmar

Reputation: 27438

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 !

Upvotes: 5

Related Questions