10
You can look at the value of the reused cell and if its not the same - then recreate it.
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyLog(@"Start Table: cellForRowAtIndexPath: %d", indexPath.row);
NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row];
UILabel *lblNew;
lblNew = [UILabel new];
UILabel *lblCell;
lblCell = [UILabel new];
MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
[cell.contentView addSubview:[lblNameArray objectAtIndex:indexPath.row]];
}
else
{
lblNew = [lblNameArray objectAtIndex:indexPath.row];
for (id label in [cell.contentView subviews])
{
if ([label isKindOfClass:[UILabel class]])
{
lblCell = label;
}
}
if (![lblNew.text isEqualToString:lblCell.text])
{
cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
[cell.contentView addSubview:[lblNameArray objectAtIndex:indexPath.row]];
}
}
return cell;