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
shouldIndentWhileEditingto NO, or with the table delegate’stableView:shouldIndentWhileEditingRowAtIndexPath:. - Changing accessory view
-
The cell’s accessory view will change automatically in accordance with its
editingAccessoryTypeoreditingAccessoryView. 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access