有时我们项目里使用tableview时会出现cell重用现象,那是因为cell被放到一个重用池里,后面的cell在创建时就会拿这个池子里cell,,,上代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
IndexDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"Celld%ld", (long)[indexPath row]]];
if (cell == nil) {
cell = [[IndexDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[NSString stringWithFormat:@"Celld%ld", (long)[indexPath row]]];
cell.mode = self.dataSourse[indexPath.row];
}
return cell;
}