用animation添加/删除UITableViewCell?
我知道这可能听起来像一个愚蠢的问题,但我已经看过每一个地方。 我怎样才能做到这一点?
我知道如何用swype-to-delete方法来做到这一点,但是如何在这个function之外做到这一点呢?
请张贴一些代码示例。
 谢谢! 
 库尔顿 
[self.tableView beginUpdates]; [self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade]; [self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade]; [self.tableView endUpdates];   insertIndexPaths是要插入到表中的NSIndexPaths的数组。 
  deleteIndexPaths是要从表中删除的NSIndexPaths数组。 
索引path的arrays格式示例:
 NSArray *insertIndexPaths = [[NSArray alloc] initWithObjects: [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0], [NSIndexPath indexPathForRow:2 inSection:0], nil]; 
在Swift 2.1+
 tableView.beginUpdates() tableView.deleteRowsAtIndexPaths([YourIndexPathYouWantToDeleteFrom], withRowAnimation: .Fade) tableView.insertRowsAtIndexPaths([YourIndexPathYouWantToInsertTo], withRowAnimation: .Fade) tableView.endUpdates() 
你可以很容易地创build一个NSIndexPath:
 NSIndexPath(forRow: 0, inSection: 0) 
 你需要这两个方法: insertRowsAtIndexPaths:withRowAnimation:和deleteSections:withRowAnimation:它们都在UITableView文档中详细说明 。