Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UITableView "'Attempt to create two animations for cell'"

I have a customTableView cell - I want to just update on cell (based on a network event occuring).

So when I first make the network call I do:

 - (void)makeNetworkCall  {        [self.tableView beginUpdates];        // MAKE_NETWORK_CALL        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]                      withRowAnimation:UITableViewRowAnimationNone];          [self.tableView endUpdates]; // SIGABRT OCCURS HERE ON SECOND CALL  }   - (void)networkDataReturned:(NSDictionary*)dataReturned  {      // UPDATE_TABLE_VIEW_DATA_MODEL              [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]                      withRowAnimation:UITableViewRowAnimationNone];    } 

This works perfectly the first time the network event is called, however if the cell is tapped (thus calling the network event again, the result of which has now been cached) I get the following error:

2011-06-22 11:19:11.262 App[3991:707] *** Assertion failure in -[_UITableViewUpdateSupport _setupAnimationsForExistingVisibleCells], /SourceCache/UIKit/UIKit-1448.89/UITableViewSupport.m:288 2011-06-22 11:19:11.327 App[3991:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempt to create two animations for cell' *** Call stack at first throw: (     0   CoreFoundation                      0x32c7664f __exceptionPreprocess + 114     1   libobjc.A.dylib                     0x36eb9c5d objc_exception_throw + 24     2   CoreFoundation                      0x32c76491 +[NSException raise:format:arguments:] + 68     3   Foundation                          0x32894573 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62     4   UIKit                               0x35f59d3b -[_UITableViewUpdateSupport(Private) _setupAnimationsForExistingVisibleCells] + 402     5   UIKit                               0x35f58b81 -[_UITableViewUpdateSupport initWithTableView:updateItems:oldRowData:newRowData:oldRowRange:newRowRange:context:] + 296     6   UIKit                               0x35f57dc1 -[UITableView(_UITableViewPrivate) _updateWithItems:withOldRowData:oldRowRange:newRowRange:context:] + 972     7   UIKit                               0x35f57473 -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 4750     8   UIKit                               0x35f612f9 -[UITableView endUpdatesWithContext:] + 28     9   UIKit                               0x35f612d5 -[UITableView endUpdates] + 16     10  App                             0x0005a033 -[CustomTableViewController tableView:didSelectRowAtIndexPath:] + 574 
like image 538
DAve Avatar asked Jun 22 '11 10:06

DAve


2 Answers

To anybody that encounters this situation again, make sure there are not repeated indexPaths in the array being passed to reload, delete or insertRowsAtIndexPaths.

like image 114
jjramos Avatar answered Sep 24 '22 10:09

jjramos


I got this error by telling tableview to reloadSection twice.

like image 37
mackworth Avatar answered Sep 21 '22 10:09

mackworth