我有类似的问题(iOS 8,iPhone 6 模拟器)
就我而言,我有一个自定义单元格,其中包含在样式单元格之间或样式单元格与节页脚DatePicker
之间插入/删除的内容,它按预期工作。Right Detail
Right Detail
[self.table beginUpdates];
if (isVisible) {
[self.table insertRowsAtIndexPaths:@[index]
withRowAnimation:UITableViewRowAnimationMiddle];
} else {
[self.table deleteRowsAtIndexPaths:@[index]
withRowAnimation:UITableViewRowAnimationMiddle];
}
[self.table endUpdates];
但是我还在Right Detail
样式单元格和部分末尾之间插入/删除了Right Detail
样式单元格,使用相同的代码没有按预期工作。出现/消失的单元格在上面的单元格顶部/通过上面的单元格可见,并且单元格移动了应有的两倍。在下图中,人物出现在动画中间的隐私下方。

但是,我注意到当 beginUpdates/endUpdates 被注释掉时,单元格只移动了大约一半的单元格高度而不是两倍的单元格高度,这意味着它看起来有了很大的改进。
我还尝试设置 zPosition,这似乎会在单元格重叠时降低可见性。
// [self.table beginUpdates];
if (isVisible) {
[self.table insertRowsAtIndexPaths:@[index]
withRowAnimation:UITableViewRowAnimationMiddle];
} else {
cell = [self.table cellForRowAtIndexPath:peopleIndex];
cell.layer.zPosition = -1;
[self.table deleteRowsAtIndexPaths:@[peopleIndex]
withRowAnimation:UITableViewRowAnimationMiddle];
}
// [self.table endUpdates];
