Je reçois un problème étrange. J'ai un UITableViewCell personnalisé et chaque cellule a un UIButton et UITextField. Lorsque le bouton est cliqué, il change la valeur du champ de texte en une constante.cellForRowAtIndexPath insertion dans le tableau
maintenant dans la méthode cellForRowAtIndexPath je ceci:
folderTitleTextView.tag=indexPath.row;
[arrayOfTextFields insertObject:folderTitleTextView atIndex:indexPath.row];
NSLog(@"indexpath.row:%i", indexPath.row);
NSLog(@"text fields count %i", [arrayOfTextFields count]);
Donc, si j'ai deux cellules, puis à chaque fois que je recharge la table, il ajoute deux objets aux arrayofTextFields, même si elle doit remplacer le ceux qui existent Donc, si j'ai deux cellules et je recharge la table 3 fois, puis pour certains arrayOfTextFields raison compte est 8.
Merci pour votre aide. J'ai été capable de résoudre le problème avec ceci: 'if (indexPath.row <[arrayOfTextFields count]) [arrayOfTextFields remplacerObjectAtIndex: indexPath.row withObject: folderTitleTextView]; sinon [arrayOfTextFields addObject: folderTitleTextView]; ' – Snowman
Très cool! Je suis content que vous l'ayez corrigé, @mohabitar. – chown