Programmaticlaly moving rows with animation in UITableView

Viewed 17856

I want to move a row to the bottom of my UITableView with cool animation effect just like in this Grocery Shopping List app.

Just like we can move rows with reordering control like:

reordering uitableview rows programmatically

How can I create such animation?

3 Answers

Important: This answer assumes iPhone OS 3.x. See the answer above for iOS 5.x

I don't know what is the "cool animation effect just like in Grocery Shopping List app". Not everyone has that app.


Rows cannot be moved programmatically.

However, you can simultaneously insert and delete a row to simulate a move.

[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:rowToMove]
                 withRowAnimation:UITableViewRowAnimationLeft];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToMoveTo]
                 withRowAnimation:UITableViewRowAnimationLeft];
// update your dataSource as well.
[tableView endUpdates];
Related