gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 06:09:38 28 4
gpt4 key购买 nike

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

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com