Je suppose que vous essayez ceci dans cellForRowAtIndexPath.
Selon le UITableViewCell class reference:
Note: Si vous voulez changer la couleur d'arrière-plan d'une cellule (en définissant la couleur de fond d'une cellule via la propriété backgroundColor déclarée par UIView) vous doit le faire dans le tableView: willDisplayCell: forRowAtIndexPath: méthode du délégué et non dans tableView: cellForRowAtIndexPath: de la source de données.
donc faire ceci:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor redColor]; //must do here in willDisplayCell
cell.textLabel.backgroundColor = [UIColor redColor]; //must do here in willDisplayCell
cell.textLabel.textColor = [UIColor yellowColor]; //can do here OR in cellForRowAtIndexPath
}
Si vous avez besoin contrôle plus précis sur l'écran cellulaire, un moyen facile est de le concevoir dans IB et le charger de la pointe en cellForRowAtIndexPath. Reportez-vous à la section «Chargement de la table personnalisée - Affichage des cellules à partir de fichiers Nib» dans this page dans le Guide de programmation de vue de table.
Génial, cherchait partout. Merci –