来自UITableView的deleteRowsAtIndexPaths的不规则animation:withRowAnimation:

摘要 :在编辑模式下,我使用自定义编辑控件删除表格视图中的行,而不是使用默认的红色减号和删除确认button。 勾选一行或多行,然后点击工具栏中的删除button。 这与在“邮件”应用程序中看到的行为类似。 请参阅下面的截图。

在这里输入图像说明

问题 :调用deleteRowsAtIndexPaths:withRowAnimation:所产生的animation是不规则的。 例如,下面是使用底行animation(即UITableViewRowAnimationBottom )删除屏幕截图中打勾的行(Subject#7)时发生的情况:

  1. 标题#8在标题#7下方和后面滑动
  2. 主题#8暂时隐藏在主题#7之后
  3. 标题#8动听地replace标题#7

这在模拟器和设备上都会发生。 自动animationtypes(即, UITableViewRowAnimationAutomatic )在删除上述主题#7时会产生相同的不规则行为。

Topanimationtypes在模拟器中按预期工作,但会在设备上产生不一致的animationanimation。

淡入淡出typesanimation是在模拟器和设备上按预期工作的唯一animation。

详情

我针对iOS 7,并使用故事板,纯自动布局和核心数据。

下面是删除行的操作方法:

 - (void)deleteButtonTapped:(UIBarButton *)sender { // update table view's data [self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows]; // create index paths for ticked rows NSMutableArray *indexPaths = [[NSMutableArray alloc] init]; [self.indexSetOfTickedRows enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) { [indexPaths addObject:[NSIndexPath indexPathForRow:idx inSection:0]]; }]; [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationBottom]; // update Core Data and UI... } 

我曾经尝试过:

表格单元格子类覆盖layoutSubviews 。 然而,即使我注释layoutSubviews时,不规则的animation仍然存在。

我还从表格单元格中删除了自定义的可打单的编辑控件,然后在操作方法中对特定行的删除进行了硬编码。 不规则的animation持续存在。

正如其他人所build议的,我已经尝试调用deleteRowsAtIndexPaths:withRowAnimation:beginUpdatesendUpdates 。 这不能解决问题。

任何关于下一步做什么的build议,或者最好的猜测为什么我看到这些不规则的animation?

更新(iOS 7.1):

定位iOS 7.1后仍然存在问题。 将继续依靠淡入淡出的animation。

尝试调用[self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows]; 在函数的结尾,而不是在开头。

尝试添加[tableView beginUpdates];[tableView endUpdates];

也许按照这里的build议设置单元格上的alpha。 不知道。 删除ios7中TableView的最后一行时animation问题