0

In my app I want to allow the user to press a button that enables them to change the order of the tableview cells.

I am using [tableView setEditing:YES animated:YES];

However, when the user presses the button and then scrolls, the cells that were not visible when the button was pressed do not have editing mode enabled.

I read this in Apple's documentation: "When you call this method with the value of editing set to true, the table view goes into editing mode by calling setEditing(_:animated:) on each visible UITableViewCell object."

Is there a way to enable all cells to be in editing mode despite not being visible when editing mode is enabled?

Here are some snapshots:

After enabling editing mode

After scrolling

Dima
  • 23,484
  • 6
  • 56
  • 83

1 Answers1

1

When you call[tableView setEditing:YES animated:YES]; you can also do something like set a custom BOOL property to YES to indicate that other cells should be in editing mode when they are displayed.

Then, in your UITableViewDelegate, you can implement the - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath method and call setEditing(_:animated:) on the cell if your editing flag is YES. Just make sure to also set the flag to NO when you don't want this to happen anymore.

Dima
  • 23,484
  • 6
  • 56
  • 83