3つのセクションを持つUITableViewがあり、2番目のセクションには編集モードでの挿入と削除のインジケーターを示すテーブルがあります。cellForRowAtIndexPathに挿入行のセルを追加しています:編集がYESの場合。また、テーブルが編集モードになると、セクションの数を減らして3番目のセクションが表示されないようにします(編集モードのときに非表示にするボタンがあります)。setEditingで[self.tableViewreloadData]を呼び出さない限り、挿入行は表示されませんが、呼び出すとアニメーションが表示されません。私は何が間違っているのですか?
- (void)setEditing:(BOOL)flag animated:(BOOL)animated
{
[super setEditing:flag animated:YES];
[self.tableView setEditing:flag animated:YES];
//unless i add [self.tableView reloadData] i don't see the + row, but then there is no animation
[self.tableView reloadData];
セクションの数を決定するために私はこれを行っています
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.editing ? 2 : 3;
}
挿入行を追加するには、cellForRowAtIndexPathでこれを実行しています
if (indexPath.row == [[[self recipe] tasks] count])
{
cell.textLabel.text = @"Add task...";
cell.detailTextLabel.text = @"";
どんな助けでも大歓迎です。これにどれだけの時間を無駄にしたかを言うのは恥ずかしいです!