わかりました、私は立ち往生しています。これは私の以前の投稿の拡張です。これが私がやろうとしていることです。
ナビゲーションバーに[編集]ボタンがあり、押すと1つのセクションのテーブルビューの先頭にセルが追加されます。このセルの目的は、を使用して新しいデータをテーブルに追加できるようにする場合です。したがって、編集スタイルは挿入です。テーブルの残りのセルは、削除の編集スタイルで構成されています。
これが私のseteditingメソッドです:
- (IBAction) setEditing:(BOOL)isEditing animated:(BOOL)isAnimated
{
[super setEditing:isEditing animated:isAnimated];
// We have to pass this to tableView to put it into editing mode.
[self.tableView setEditing:isEditing animated:isAnimated];
// When editing is begun, we are adding and "add..." cell at row 0.
// When editing is complete, we need to remove the "add..." cell at row 0.
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
NSArray* path = [NSArray arrayWithObject:indexPath];
// fill paths of insertion rows here
[self.tableView beginUpdates];
if( isEditing )
[self.tableView insertRowsAtIndexPaths:path withRowAnimation:UITableViewRowAnimationBottom];
else
[self.tableView deleteRowsAtIndexPaths:path withRowAnimation:UITableViewRowAnimationBottom];
[self.tableView endUpdates];
// We nee to reload the table so that the existing table items will be properly
// indexed with the addition/removal of the the "add..." cell
[self.tableView reloadData];
}
コードでこの余分なセルを考慮していますが、2つのインデックスパス=[0,0]-テーブルの新しいセルと古い元の最初のセルがあります。setEditingでテーブルビューセルを再読み込みする呼び出しを追加すると、セルのインデックスが再作成されますが、テーブルビューはアニメーション化されなくなりました。
私もケーキが欲しいです。私がやろうとしていることを達成し、アニメーションを維持する別の方法はありますか?
-ジョン