这以前有效,除非它已经很长时间我忽略了一些东西。当表格第一次显示时,一切看起来都很棒,但是如果我上下滚动标签会得到重复的内容。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UILabel *labelName = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, tableView.frame.size.width, 35)];
labelName.tag = 20;
[cell addSubview:labelName];
}
((UILabel *)[tableView viewWithTag:20]).text = [data objectAtIndex:indexPath.row];
return cell;
}