0

アイテムを選択すると、そのセル内のオブジェクトに関する情報が変更され、セルが一番下に移動して、テーブルデータが再読み込みされるテーブルがあります。

//update model
...

//move cell to bottom
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:lastIndex inSection:0]] withRowAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];

//reload cells
[tableView reloadData];

現在は機能しますが、アニメーションが終了するのを待ちません。データをリロードする前に、アニメーションの挿入と削除が完了するのを待つにはどうすればよいですか?または、それを行うためのより良い方法がある場合は、それも知っておくとよいでしょう。

4

1 に答える 1

1

Simple, instead of removing a cell and then immediately adding a new one, you could use UITableView's moveRowAtIndexPath which will animate the cell from its starting point to its ending point.

[tableView moveRowAtIndexPath:[NSArray arrayWithObject:indexPath] toIndexPath:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:lastIndex inSection:0]]];
于 2012-12-06T14:30:57.217 に答える