2010-07-20 4 views
0

Je suis confronté à un problème très étrange avec la méthode editingStyleForRowAtIndexPath. Je prévois de changer l'apparence des cellules modifiables. Cela fonctionnait correctement, mais lorsque je fais défiler la table, je n'obtiens pas le pointeur de cellule de table dans la méthode de délégué editingStyleForRowAtIndexPath. Ainsi, les nouvelles cellules n'obtiennent pas l'apparence personnalisée.editingStyleForRowAtIndexPath Problème de défilement

J'utilise ce -

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    // get tablviewcell pointer 
    UITableViewCell* pCell = [tableView cellForRowAtIndexPath:indexPath]; // <- not getting the pointer when scrolling the table and new cells come up 

     //Changin cell appearance here ... 




} 

Merci à l'avance!

Répondre

1

Je pense que la vue table peut appeler cette méthode avant d'affecter une cellule au chemin d'index donné. Un moyen plus fiable de personnaliser les cellules de vue de table serait de surcharger -tableView: willDisplayCell: forRowAtIndexPath :. Vous pouvez tester la propriété editingStyle de la cellule et agir en conséquence.

+1

Bonjour Costique, Je viens de vérifier cela et a constaté que les méthodes exécutent dans cet ordre 1) - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath 2) - (UITableViewCellEditingStyle) tableView : (UITableView *) tableView editingStyleForRowAtIndexPath: (NSIndexPath *) indexPath 3) - (void) tableView: (UITableView *) tableView willDisplayCell: (UITableViewCell *) forRowAtIndexPath cellulaire: (NSIndexPath *) indexPath Mais je ne suis pas en mesure d'obtenir la cellule dans la 3ème méthode elle-même. S'il vous plaît aider !! – Saurabh

+0

Étrange. Qu'est-ce que la vue table envoie en tant que paramètre de cellule (le second) dans -tableView: willDisplayCell: forRowAtIndexPath :? La méthode est-elle appelée du tout? Si ce n'est pas le cas, vérifiez si l'objet implémentant la méthode est réellement le délégué de la vue de table. – Costique

Questions connexes