reordering control in UITableView

Viewed 11207

I am developing a game in which I am using a UITableView which has custom cell (UItableViewCell subclass).

In editing mode: Only the reordering control of the UITableView should show.

Right now I am getting the delete and the reordering control.

How to get only reordering control while editing ?

5 Answers

Swift 5.0

If you want to disable all other editing options for your tableView's cells except the one that allows you to reorder them then just implement those methods from UITableViewDelegate:

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

// Removes the ability to delete current cell
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
    .none
}

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