我知道这可能听起来像一个愚蠢的问题,但我到处都看过。我怎样才能做到这一点?
我知道如何使用 swype-to-delete 方法执行此操作,但是我如何在该功能之外执行此操作?
请发布一些代码示例。
谢谢!库尔顿
最佳答案
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
insertIndexPaths
是要插入到表中的 NSIndexPaths 数组。deleteIndexPaths
是要从表中删除的 NSIndexPaths 数组。索引路径的示例数组格式:
NSArray *insertIndexPaths = [[NSArray alloc] initWithObjects:
[NSIndexPath indexPathForRow:0 inSection:0],
[NSIndexPath indexPathForRow:1 inSection:0],
[NSIndexPath indexPathForRow:2 inSection:0],
nil];
关于objective-c - 添加/删除带有动画的 UITableViewCell?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5560602/