UITableViewRowAnimationNone - 表现为UITableViewRowAnimation(上/下)

Mic*_*ael 5 uitableview uiview caanimation ios

我已使用以下代码设置行插入.我只UITableViewRowAnimationNone在插入和删除行时使用,但有时,正如您在下面的gif中看到的那样,该行从顶部或底部开始动画.在大多数情况下,它没有动画,因为我想要它,但有时它在插入和删除时动画.我不是在谈论扩展显示插入单元格的表格视图,我的意思是单元格似乎从底部或顶部滑入.

在此输入图像描述

以下是控制插入动画的方法:

- (void)contentHeaderFooterView:(NFContentHeaderFooterView *)headerFooterView sectionOpened:(NSInteger)section{

    NSIndexPath *pathToAdd = [NSIndexPath indexPathForRow:0 inSection:section];

    [self.tableView beginUpdates];
    [self.tableView insertRowsAtIndexPaths:@[pathToAdd] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView endUpdates];

}
Run Code Online (Sandbox Code Playgroud)

这是控制删除动画的方法.

- (void)contentHeaderFooterView:(NFContentHeaderFooterView *)headerFooterView sectionClosed:(NSInteger)section{

    NSIndexPath *pathToDelete = [NSIndexPath indexPathForRow:0 inSection:section];

    [self.tableView beginUpdates];
    [self.tableView deleteRowsAtIndexPaths:@[pathToDelete] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView endUpdates];

}
Run Code Online (Sandbox Code Playgroud)

Ben*_*ent 0

我也遇到过类似的问题,即表更新未执行我直接提供的动画。我不能确定为什么,但我可以建议的一件事是,您可以只进行硬重新加载数据,而不是在开始/结束更新之间执行特定的行删除。