Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView commitEditingStyle without deleting cell
    text
    copied!<p>I have small problem with my conception of deleting rows in UITableView. After user deletes a row i do not want to fire:</p> <pre><code> [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight]; </code></pre> <p>Instead I want to change edited cell text and background without hiding it. My approach works quite well:</p> <blockquote> <pre><code>if (editingStyle == UITableViewCellEditingStyleDelete) { NSMutableArray *previous_points = [self.trip_arrayOfAllPoints mutableCopy]; [previous_points removeObjectAtIndex:indexPath.row]; self.trip_arrayOfAllPoints = nil; self.trip_arrayOfAllPoints = [[NSMutableArray alloc] initWithCapacity:[previous_points count]]; self.trip_arrayOfAllPoints = [previous_points mutableCopy]; self.trip_arrayOfAllPointsEDITED = [[NSMutableArray alloc] initWithCapacity:[previous_points count]]; self.trip_arrayOfAllPointsEDITED = [previous_points mutableCopy]; //[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight]; self.trip_isArrayOfAllPointsEDITED = YES; } </code></pre> </blockquote> <p>But after deleting a row it does not commit animation of dissapearing "DELETE" label on current cell. Is there a way around "Apple way" of deleting rows?</p> <p><strong>EDIT - I've worked it out</strong></p> <p>It's pretty simple and plain. Just replace deleteRowsAtIndexPaths with:</p> <pre><code> [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; </code></pre> <p>After this "delete" animation disappears and cell is still in it's place.</p>
 

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