表格单元指示符问题

在我的申请中我有
UITableView
&我用了
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
当我滚动这个表格时,我在多个单元格中得到多个复选标记 请帮我..     
已邀请:
一般来说,细胞来自两种方式:
- (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.

}
因为您的单元可能来自重用队列,所以它已配置。显然,您忘记重新配置来自重用队列的那些单元。     
您可以在tableView的委托方法didSelectedRowAtIndexPath上使用此示例代码 UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];         [cell setSelected:YES animated:YES];         [cell 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];
    

要回复问题请先登录注册