移动cell的位置

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView  editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleNone;
}
//移动行
-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{
    NSInteger fromRow = [sourceIndexPath row];            //获取需要移动的行
    NSInteger toRow = [destinationIndexPath row];        //获取需要移动的位置
    id object = [array objectAtIndex:fromRow];            //读取需要移动行的数据
    [array removeObjectAtIndex:fromRow];
    [array insertObject:object atIndex:toRow];
}

 

posted @ 2015-12-14 10:45  DevoutSoul  阅读(332)  评论(0)    收藏  举报