Table View Editing

A table view cell has a normal state and an editing state, according to its editing property. The editing state is typically indicated visually by one or more of the following:

Editing controls
At least one editing control will usually appear, such as a minus button (for deletion) at the left side.
Shrinkage
The content of the cell will usually shrink to allow room for an editing control. You can prevent a cell in a grouped-style table from shifting its left end rightward in editing mode by setting its shouldIndentWhileEditing to NO, or with the table delegate’s tableView:shouldIndentWhileEditingRowAtIndexPath:.
Changing accessory view
The cell’s accessory view will change automatically in accordance with its editingAccessoryType or editingAccessoryView. If you assign neither, so that they are nil, the cell’s accessory view will vanish when in editing mode.

As with selection, you can set a cell’s editing property directly (or use setEditing:animated: to get animation), but you are more likely to let the table view manage editability. Table view editability is controlled through the table’s editing property, usually by sending the table the setEditing:animated: message. The table is then responsible for putting its cells into edit mode.

Note

A cell in edit mode can also be selected by the user if the table view’s allowsSelectionDuringEditing is YES. But this would be unusual.

Putting the table into edit mode is usually left up to the user. One typical device ...

Get Programming iOS 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.