Iphone 如何在xcode中对表项进行排序

Iphone 如何在xcode中对表项进行排序,iphone,xcode,sorting,Iphone,Xcode,Sorting,我是xcode新手,我一直在积极地搜索在线教程来做类似于jquery sortable的事情。我的表项的唯一区别是在一行中,但是我必须能够像item1 | item3 | item2 | item4那样重新排列它们。我还需要知道数组的最终排序结果,以便使用它搜索数据库。有人知道如何在xcode中实现这一点吗?非常感谢您的帮助。您可以使用tableView并对其单元格重新排序: #pragma mark Row reordering // Determine whether a given row

我是xcode新手,我一直在积极地搜索在线教程来做类似于jquery sortable的事情。我的表项的唯一区别是在一行中,但是我必须能够像item1 | item3 | item2 | item4那样重新排列它们。我还需要知道数组的最终排序结果,以便使用它搜索数据库。有人知道如何在xcode中实现这一点吗?非常感谢您的帮助。

您可以使用tableView并对其单元格重新排序:

#pragma mark Row reordering
// Determine whether a given row is eligible for reordering or not.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
     return YES;
}
// Process the row move. This means updating the data model to correct the item indices.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
        toIndexPath:(NSIndexPath *)toIndexPath
{
     NSString *item = [arry objectAtIndex:fromIndexPath.row];
    [arry removeObject:item];
    [arry insertObject:item atIndex:toIndexPath.row];
}
但这用于每行一项