0

UISegmentedControlテーブルビューのデータを変更するがあります。

[self.mySexyTableView reloadRowsAtIndexPaths:updatedPaths withRowAnimation:UITableViewRowAnimationTop];

タブ 1 に 5 行、タブ 2 に 2 行を表示するとします。2 番目のタブをクリックすると、最初の 2 行が新しい値を取得しますが、行 3 から 5 のタブ 1 の古いデータが残ります。どうすればそれらをクリアできますか?

4

1 に答える 1

1

チェックアウトするための簡単なサンプルコードを次に示します: iPhoneCoreDataRecipes

トピックについては、提供されている最も優れたメソッドの 1 つを次に示します。

// If I want to delete the next 3 cells after the one you click
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  NSMutableArray* indexPaths = [NSMutableArray array];
  for (int i = indexPath.row + 1; i < indexPath.row + 4; i++)
  {
    [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
  }

  [tableView beginUpdates];
  [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
  [tableView endUpdates];
  [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

この問題に遭遇しました。正しく理解していれば、更新してもセルが削除されないということです。したがって、それらを削除してから更新を呼び出してください。幸運を!

于 2009-07-24T01:20:35.673 に答える