Instance Method

moveRowAtIndexPath:toIndexPath:

Moves the row at a specified location to a destination location.

Declaration

- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;

Parameters

indexPath

An index path identifying the row to move.

newIndexPath

An index path identifying the row that is the destination of the row at indexPath. The existing row at that location slides up or down to an adjoining index position to make room for it.

Discussion

You can combine row-move operations with row-insertion and row-deletion operations within a beginUpdatesendUpdates block to have all changes occur together as a single animation.

Unlike the row-insertion and row-deletion methods, this method does not take an animation parameter. For rows that are moved, the moved row animates straight from the starting position to the ending position. Also unlike the other methods, this method allows only one row to be moved per call. If you want multiple rows moved, you can call this method repeatedly within a beginUpdatesendUpdates block.

See Also

Inserting, Deleting, and Moving Rows and Sections

- insertRowsAtIndexPaths:withRowAnimation:

Inserts rows in the table view at the locations identified by an array of index paths, with an option to animate the insertion.

- deleteRowsAtIndexPaths:withRowAnimation:

Deletes the rows specified by an array of index paths, with an option to animate the deletion.

- insertSections:withRowAnimation:

Inserts one or more sections in the table view, with an option to animate the insertion.

- deleteSections:withRowAnimation:

Deletes one or more sections in the table view, with an option to animate the deletion.

UITableViewRowAnimation

The type of animation to use when rows are inserted or deleted.

- moveSection:toSection:

Moves a section to a new location in the table view.