当前位置: 代码迷 >> Iphone >> tableview多选时选了一条,同时把第十条纪录也选择了的有关问题
  详细解决方案

tableview多选时选了一条,同时把第十条纪录也选择了的有关问题

热度:60   发布时间:2016-04-25 06:31:43.0
tableview多选时选了一条,同时把第十条纪录也选择了的问题
在创建cell的时候没什么问题吧?求大神!!!

代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"SimpleTableIdentifier";
   
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   
  if (cell == nil) {
  cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  }
  int row = [indexPath row];
  NetContactersModel *model = [self.netContacters objectAtIndex: row];
  cell.textLabel.text = model.userName;
  return cell;
}

------解决方案--------------------
创建没问题。选项的代码你可以贴上来看看。
------解决方案--------------------
重用了同一个cell的问题,
在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
里面判断下,重新设置下选中状态
  相关解决方案