我知道这听起来可能是个愚蠢的问题,但我到处都看过。我该怎么做?
我知道如何使用 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];
https://stackoverflow.com/questions/5560602/