0

私はxcodeを初めて使用します。オンラインチュートリアルを積極的に検索して、jquery sortable link hereのようなことをしています。私のテーブル項目が単一の行にある唯一の違いですが、 item1|item3|item2|item4のように再配置できる必要があります。また、データベースの検索に使用できるように、配列の最終的な並べ替え結果も知る必要があります。xcodeでこれを行う方法を知っている人はいますか? お役に立てば幸いです。

4

1 に答える 1

0

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];
}

ただし、これは行ごとに 1 つの項目に使用されます。

http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/ManageReorderRow/ManageReorderRow.html

于 2013-03-17T01:43:47.967 に答える