DAv*_*Ave 27 core-animation uitableview ios
我有一个customTableView单元格 - 我想只更新单元格(基于发生的网络事件).
所以,当我第一次拨打网络电话时,我做了:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
这在第一次调用网络事件时完美地工作,但是如果单元被轻击(因此再次调用网络事件,其结果现在已被缓存),我得到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
它\xe2\x80\x99很难理解你\xe2\x80\x99是如何导致该错误消息的,但是尝试将你的表重新加载代码移动到一个单独的方法中,并在现在有两个相同的代码块的地方调用它。这可能会解决某种奇怪的竞争条件,UITableView无论如何,这种条件应该会自行过滤掉。
| 归档时间: |
|
| 查看次数: |
11782 次 |
| 最近记录: |