- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ThirdTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThirdTableViewCell"];
UILabel * label = (UILabel*)[cell.contentView viewWithTag:501];// ------先按照tag值试着去Cell中找,是否有标签
if (label == nil) {// ------如果没找到再新建
label = [[UILabel alloc]init];
label.tag = 501;
label.frame = CGRectMake(0, 0, 200, 20);
[cell.contentView addSubview:label];
}
label.text = [NSString stringWithFormat:@"%ld", indexPath.row];
cell.titleLabel.text = [NSString stringWithFormat:@"Section:%ld---Row:%ld", indexPath.section, indexPath.row];
return cell;
}
网友评论