我有以下几行代码:
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableViewData removeObjectAtIndex:indexPath.row]; // Step 1
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade]; // Step 2
if (!queue_C5K) { // Step 3
LockrNotificationDataKeeper *LLDK =
[[LockrNotificationDataKeeper alloc] initWithData:@"##deletion##"
andIndexPath:(int)indexPath.row
andType:@"dR"
delegate:self];
[queue_C5K addOperation:LLDK];
}
}
}
因此,我在第 1 步中从当前 UITableView
数据中删除了选定的 UITableViewCell
。在第 2 步中,应该会发生动画
。在第 3 步中,所选数据将从 datasource
(plist) 中删除。第 3 步的回调将重新加载我的 UITableView
。
问题是,只有最后一个 UITableViewCell
会随着动画移除。所有上层 UITableViewCells
都不需要。因此,如果我有 5 个单元格,前 4 个单元格在删除它们时没有任何动画。
我做错了什么?
最佳答案
The callback of Step 3 will reload my tableView.
你调用[tableView reloadData]
了吗?调用deleteRowsAtIndexPaths
后,在淡入淡出动画期间,如果调用reloadData
,淡入淡出动画将被覆盖,则无法得到任何淡入淡出结果。因为 reloadData 不会影响数据已经被移除的最后一行,所以最后一行单元格有淡入淡出的动画。
关于iOS:UITableViewRowAnimationFade 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22354719/