iOS:UITableViewRowAnimationFade 无法正常工作

标签 ios uitableview tableview

我有以下几行代码:

- (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/

相关文章:

ios - UINavigationController 在 iOS6 中崩溃

ios - swift : Switching tableview cells in cellForRowAtIndexPath

ios - 按日期对 TableView 进行分组和排序

ios - Mapview swift 添加多个标记

ios - 什么时候调用 ViewWillLayoutSubviews 和 ViewDidLayoutSubviews 方法?

ios - fatal error : unexpectedly found nil while unwrapping an Optional value in Swift 3

iphone - 自定义 UITableViewCell 与字幕样式

ios - 紧急联系电话可以修改吗

iphone - UITableViewCell 分隔符未显示

Swift/Firebase - 按日期对表格 View 中的帖子进行排序