1

I have implemented these methods:

 func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
  {
    return true
  }

  func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

    if (editingStyle == UITableViewCellEditingStyle.delete) {
      showAlertToDeleteDevice()
    }
  }

and set breakpoints into it, but there is no call back of these function. -cellForRowAtIndexPath and -didSelectRowAtIndexPath functions works perfect which means that all is good with dataSource and Delegate connection.

What can be a problem? Because I don't see delete button by swiping. In the same time for I see delete button for my other table.

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
  • 1
    Possible duplicate of [UITableViewCell, show delete button on swipe](http://stackoverflow.com/questions/3309484/uitableviewcell-show-delete-button-on-swipe) – zisoft Nov 22 '16 at 07:28

2 Answers2

1

You use wrong function.

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return true
}

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if (editingStyle == UITableViewCellEditingStyle.Delete) {
        // delete action
    }
}
Vitali Eller
  • 125
  • 7
1

You have to implement

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
gasho
  • 1,926
  • 1
  • 16
  • 20