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:
- How can I replicate this behavior, such that the Edit button changes state when an individual row enters/exits edit mode?
- What other behaviors of the
UITableViewController‘seditButtonItemmight I need to replicate?
I have such a case in my own app. I implemented the following table view delegate methods: