1

私のアプリケーションでは、私は使用していUITableViewます

[cell setAccessoryType:UITableViewCellAccessoryCheckmark];

このテーブルをスクロールすると、複数のセルに複数のチェックマークが表示されます

私を助けてください..

4

2 に答える 2

1

このサンプル コードは、tableView のデリゲート メソッド didSelectedRowAtIndexPath で使用できます。

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [セル setSelected:YES アニメーション:YES]; [セル setAccessoryType:UITableViewCellAccessoryCheckmark];

    for(int iterator=0;iterator<3;iterator++)
    {

        UITableViewCell *eachCell = [[self tableView] cellForRowAtIndexPath:[NSIndexPath indexPathForRow:iterator inSection:0]];
        [eachCell setSelected:NO animated:YES];
        [eachCell setAccessoryType:UITableViewCellAccessoryNone];
    }

    UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
    [newCell setSelected:YES animated:YES];
    [newCell setAccessoryType:UITableViewCellAccessoryCheckmark];
于 2011-07-29T13:21:20.507 に答える
1

一般に、セルは次の 2 つの方法で取得されます。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

  static NSString *identifier = @"Cell";
  UITableViewCell *cell = ... // The cell come from reuse queue.
  if (cell == nil) {
      cell = ... // if reuse queue has no cell, then create an autoreleased cell
  } 

  // Configure cell by indexPath.
  // You should configure cell HERE.

}

セルは再利用キューから来る可能性があるため、構成されました。明らかに、再利用キューからのセルを再構成するのを忘れています。

于 2011-03-15T10:50:58.260 に答える