使用动画将uitableview单元格移动到顶部

mar*_*101 2 objective-c uitableview ios xcode5

简单,我是新手!

所以我有一个uitableview,其中包含可以从Web服务更改的每个单元格中的内容.

我需要在视觉上显示任何单元格中的某些内容发生变化.因此,我希望在该单元格的内容发生变化时将特定单元格移动到顶部...动画!

这可能吗??怎么做呢?

ign*_*rum 6

无法以编程方式移动行.

但是,您可以同时插入和删除行以模拟移动.

[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:rowToMove]
                 withRowAnimation:UITableViewRowAnimationLeft];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToMoveTo]
                 withRowAnimation:UITableViewRowAnimationLeft];
// update your dataSource as well.
[tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)


Dyl*_*lan 6

之前选择的答案可能是正确的,但是从iOS 5开始,您可以这样做:

[tableView moveRowAtIndexPath:indexPathOfRowToMove toIndexPath:indexPathOfTopRow];
Run Code Online (Sandbox Code Playgroud)