iOS开发学习之#表视图#(3)移动行

来源:互联网 发布:淘宝货源 客户达 编辑:程序博客网 时间:2024/04/29 22:40

继续上篇接下来介绍移动行:移动行我们用

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath

(UITableView *)tableView用来指定表视图,(NSIndexPath *)sourceIndexPath用来指定要移动行的索引路径,(NSIndexPath *)destinationIndexPath用来指定行移动到目标位置的索引路径
核心代码:
<pre name="code" class="objc">//移动行- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{    NSInteger fromRow = [sourceIndexPath row];    NSInteger toRow = [destinationIndexPath row];    id object = [a objectAtIndex:fromRow];    [a removeObjectAtIndex:fromRow];    [a insertObject:object atIndex:toRow];}




0 0
原创粉丝点击