First use the following settings:
self.tableView.allowsMultipleSelectionDuringEditing = true self.tableView.setEditing(true, animated: false)
And we implement the following delegate methods:
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return self.shouldAllowSelectionAt(indexPath) } func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { return self.shouldAllowSelectionAt(indexPath) } func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { if self.shouldAllowSelectionAt(indexPath) { return indexPath } return nil }
shouldAllowSelectionAt is my private method that contains logic about which row to select
source share