Unable to swipe to delete with tableview using diffable data source in iOS 13
You should subclass UITableViewDiffableDataSource
and return true
for the rows you want to enable this for in:
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
It's true that the docs for tableView(_:canEditRowAt:)
say:
The method permits the data source to exclude individual rows from being treated as editable. Editable rows display the insertion or deletion control in their cells. If this method is not implemented, all rows are assumed to be editable
However UITableViewDiffableDataSource
, does implement that method and it seems to return false
by default (though I can't find that documented anywhere).
In fact the sample code from WWDC 2019 sessions 215 and 220 implements a custom UITableViewDiffableDataSource
subclass like this:
class DataSource: UITableViewDiffableDataSource<SectionType, ItemType> {
// ...
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
// ...
}