继续上篇接下来介绍移动行:移动行我们用
- (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]; }
原文地址:http://blog.csdn.net/u010710758/article/details/41649071