有時我們項目裏使用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;
}