ios - 动画不适用于 UITableView deleteRowsAtIndexPaths :withRowAnimation:

标签 ios animation uitableview delete-row

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

此代码(在方法 commitEditingStyle 中)在删除行时不会对动画进行任何更改。该行被删除,其他一切运行良好,除了动画。

无论我将动画样式更改为什么,它都只是从左到右删除文本,同时通过向上移动来删除该行。最后一行也做了一件奇怪的事情。它会删除文本并删除行,但不会同时删除行。

这是 iOS 7 中的默认行为吗?我不明白为什么会这样。

附言我不知道为什么,但 insertRowsAtIndexPaths 动画似乎工作正常。

[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:ip] withRowAnimation:UITableViewRowAnimationRight];

最佳答案

尝试

 [self.tableView beginUpdates];

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

[self.tableView endUpdates];

还要确保 TableView 的数据源与 TableView 发生的情况同步。

我通常有一个数组作为数据源,我会覆盖它的 setter,这样它就始终保持同步。

希望对你有帮助

关于ios - 动画不适用于 UITableView deleteRowsAtIndexPaths :withRowAnimation:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19989310/

相关文章:

css - 应该是:hover pseudo state style change work after CSS animation completes

ios - Uitableviewcell 具有自定义 View ,在应用程序运行时无法正确调整大小(下图)

苹果手机 : uitableview : contents of a cell change on scrolling

ios - 如何检查 NSDictionary 值在 iPhone 中为零

ios - 设置 PreferredContentSize 在 iOS8 横向 iPhone 的今日小部件中不起作用

ios - 如何检测哪个 UITableView 正在滚动

IOS7 tableview底部的viewcontrol中多余的空间

ios - libc++abi.dylib : terminating with uncaught exception of type NSException without the regular error message

python - 如何在创建动画之前创建绘图?

javascript - 如何在点击时播放关键帧动画?