In order to enable rearrangeable (moveable) cells in my UITableView
, I must set table.isEditing
to true
and implement the following delegate methods:
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath)
I also implement the following delegate methods to hide the default table-editing UI:
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
return .none
}
func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
return false
}
I would also like to swipe-delete the cells in this table. I've tried using both the tableView(_:editActionsForRowAt:)
approach and the new iOS 11 tableView(_:trailingSwipeActionsConfigurationForRowAt:)
but neither work while table.isEditing = true
. The only other relevant table delegate method I use is:
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
which returns true
for all cells.
Is there a way to enable both of these UITableView features simultaneously? It looks possible as this is exactly how the table queue in the Apple Music app works: