Comment arrêter la cellule UITableView est en train d'écraser le contenu?

Je suis à l'aide d'un UITableView et je m'aperçois que les cellules de mon tableview sont arriver progresively plus audacieuses comme je l'ai défiler, il est d'écraser le contenu et je veux arrêter de ce mais ne peut pas voir où je vais mal.

Sur mon UITableView, pour quelque raison que quand j'ai faites défiler le contenu de la tableview obtenir foiré avec l'créés manuellement UILabel.

J'ai besoin d'un manuel UILabel parce que j'ai besoin pour des cellules plus tard.

Que j'ai faites défiler vers le haut et vers le bas, les étiquettes deviennent progressivement de plus en plus audacieux; ils se chevauchent toujours et parfois même affecte des lignes plus bas (avant même qu'ils sont dans la fenêtre d'affichage).

Si je continue à le faire, le contenu de la cellule devenir unintelligable.

Cela se produit uniquement si le backgroundColor n'est pas définie comme clearColor.

J'ai tenté [cellLabel setClearsContextBeforeDrawing:YES]; et [self.tableView setClearsContextBeforeDrawing:YES]; pas d'effet.

Si j'utilise cell.textLabel.text alors le problème semble disparaître.

Code et une image de l'échantillon suit.

  //Simple table view
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//Configure the cell...
//[self configureCell:cell atIndexPath:indexPath];
NSString *txt = @"Product";
//cell.textLabel.text = txt;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView *cellView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, cell.frame.size.height)];
UILabel *cellLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 120, 35)];
[cellLabel setText:txt];
[cellLabel setFont:[UIFont boldSystemFontOfSize:12]];
[cellLabel setBackgroundColor:[UIColor clearColor]];
[cellView addSubview:cellLabel];
[cellLabel release];
[cell.contentView addSubview:cellView];
[cellView release];
return cell;
}
Image follows;
![image of uitableview][1]
[1]: http://i.stack.imgur.com/5lNy6.png
//Edit to include context
I am using a dictionary to display the contents of the UITableViewCells.
I have attempted to do the following;
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
[self configureCell:cell atIndexPath:indexPath];
} //end if
//Configure the cell...
//
//Moved to inside the cell==nil        
return cell;
}
-(void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
//Get the txt from the Dictionary/Plist... *removed due verboseness*
UILabel *cellLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 120, 35)];
[cellLabel setText:txt];
[cellLabel setFont:[UIFont boldSystemFontOfSize:12]];
[cellLabel setBackgroundColor:[UIColor clearColor]];
[cell.contentView addSubview:cellLabel];
[cellLabel release];
}

Ce, même si elle résout le problème de l'écrasement -- il provoque un problème: il permet d'imprimer des étiquettes à plusieurs reprises apparaissent dans des endroits aléatoires -- ce qui suit est juste un exemple, d'autres champs et des étiquettes aussi de répéter.

Voir image ci-dessous;

Comment arrêter la cellule UITableView est en train d'écraser le contenu?

source d'informationauteur zardon