我有一个customTableView单元格 - 我想只更新单元格(基于网络事件发生)。iOS UITableView“'试图为单元格创建两个动画'”
所以,当我第一次做网络电话我做的:
- (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];
}
这完美的作品第一次网络事件被调用,但是如果电池被窃听(因此再次调用网络事件,结果其中已经被缓存),我收到以下错误:
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
请参阅下面的@jjramos回复。这可能不像看起来那么不那么令人费解。 – clearlight