ios*_*eak 55 objective-c uitableview ios4
我知道这可能听起来像一个愚蠢的问题,但我已经看过每一个地方.我怎样才能做到这一点?
我知道如何使用swype-to-delete方法执行此操作,但是如何在该函数之外执行此操作?
请发布一些代码示例.
谢谢!
库尔顿
Sab*_*bin 118
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)
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];
Run Code Online (Sandbox Code Playgroud)
在Swift 2.1+中
tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([YourIndexPathYouWantToDeleteFrom], withRowAnimation: .Fade)
tableView.insertRowsAtIndexPaths([YourIndexPathYouWantToInsertTo], withRowAnimation: .Fade)
tableView.endUpdates()
Run Code Online (Sandbox Code Playgroud)
您可以像这样轻松创建NSIndexPath:
NSIndexPath(forRow: 0, inSection: 0)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
48102 次 |
最近记录: |