I have a UIViewController which adds a UITableView and a UIToolbar to its view. Unfortunately I can not use a UITableViewController in this instance.
I have added the view controller's editButtonItem to the toolbar. I need to replicate the default behavior of the edit button on a UITableViewController - the edit button should be tied to the tableView and switch it in/out of edit mode.
I have overridden the UIViewController's setEditing to include the line:
[_tableView setEditing:editing animated:animated];
and this works for the most part - the table view successfully enters and exits edit mode when the editButtonItem is used.
However, there is at least one issue. On a UITableViewController, the edit button switches to 'done' when a the user slides across a row in the table. 'Done' then returns that row to it's non-editing version. Also, touching outside the row returns it to view mode, and reverts the edit button to 'Done'.
My questions:
UITableViewController's editButtonItem might I need to replicate?I have such a case in my own app. I implemented the following table view delegate methods:
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath {
[self setEditing:YES animated:YES];
}
- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
[self setEditing:NO animated:YES];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With