但是我改成把 cell 的 textLable 的 text 值存进数组,复用时取出来的就是正确的,有什么需要注意的地方吗 代码如下:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * timeRing = @"ring";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:timeRing];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:timeRing];
}else{
while ([cell.contentView.subviews lastObject]!=nil) {
[[cell.contentView.subviews lastObject] removeFromSuperview];
}
}
cell.accessoryType = UITableViewCellAccessoryNone;
if (self.cellArray.count<self.ringArray.count) {
self.timeRingItem = self.ringArray[indexPath.row];
cell.tintColor = [UIColor redColor];
cell.textLabel.text= self.timeRingItem.ringName;
[self.cellArray addObject:cell];
}
else{
cell = self.cellArray[indexPath.row];
}
return cell;
}