Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimate data refresh (soft delete) on Core Data / UITableView
    text
    copied!<p>I have a table view that's backed by a fetchedResultsController. On my table cells I have a button that performs a soft delete, as far as the view is concerned... tap the button, the selector that performs the soft delete is called, and ... something is supposed to happen (I've tried a lot of things), but nothing I've tried animates like Apple's row animations.</p> <p>I can perform simple row animations, like making it slide out of the way (which leaves a blank row until I tell the table to reload, which in turn is a bit of a jarring effect). This is the closest I've come:</p> <pre> -(void) completeTask: (id) sender { NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]]; NSDate *date = [[NSDate alloc] init]; NSManagedObject *task = [self.fetchedResultsController objectAtIndexPath:indexPath]; [task setValue:date forKey:@"complete"]; AppController *ac = [AppController sharedAppController]; NSManagedObjectContext *moc = [ac managedObjectContext]; NSError *error = nil; if(![moc save:&error]){ NSLog(@"%@ %@",error, [error description]); exit(-1); } else { UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; CGRect cellFrame = cell.frame; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.35]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(someAnimationDidStop:finished:context:)]; cell.frame = CGRectMake(cellFrame.size.width , cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height); [UIView commitAnimations]; } } -(void) someAnimationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)duration { NSLog(@"Animation Stopped"); [self fetchResults]; // this guy performs a new fetch and table data reload } </pre> <p>I feel like I'm sort of on the right track, however I don't think this is really quite the answer. I was hoping that somehow <code>controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:</code> would be the answer. My guess is that if I want the stock Apple animations, I will have to create a separate NSMutableArray to track the results and just make sure it's kept in sync.</p> <p>Thoughts and opinions? </p> <p>Thanks!!!</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