Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the view controller's "-(void)setEditing:(BOOL)editing animated:(BOOL)animated" method, override the current behaviour:</p> <pre><code> - (void)setEditing:(BOOL)editing animated:(BOOL)animated { [self.tableView beginUpdates]; // Tell the table to begin updates to ensure that the following reloads and animations all happen at once [super setEditing:editing animated:animated]; // set the table editing if you are not using UITableViewController // reload any rows that may need updating for the new state if (editing) { // tell the table view to insert the editing rows } else { // tell the table view to remove the editing rows } [self.tableView endUpdates]; // commit the updates. } </code></pre> <p>So now, as the view controller (and the table view) enters editing mode, the view controller tells to table to insert rows at the editing spot. The table itself also moves into editing mode.</p> <p>As the view controller moves out of editing (and the table view with it) the rows that were editing specific are removed.</p> <p>Note that if you're not using a UITableViewController subclass, but just a subclass of UIViewController itself, you need to tell the table view to move into editing at the same time:</p> <pre><code>[tableView setEditing:editing animated:animated]; </code></pre> <p>If you need to reload, or insert rows, etc, the delegate and datasource methods need to check if the table is in editing mode, and return the rows required for either the editing or non-editing mode.</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView.editing) { return /*editing count*/; } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView.editing) { // return cells for the editing state. } // return cells based on the standard state. } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload