L'Échec d'Assertion -[UITableView _endCellAnimationsWithContext]
Je suis l'analyse d'un fichier xml et de mettre ses valeurs analysées dans un affichage tableau.La vue de la table n'a qu'un seul article.Mais je suis d'exception suivante:
2013-10-14 15:21:57.250 tableview[6068:907] * échec d'Assertion dans -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-2380.17/UITableView.m:909
2013-10-14 15:22:11.227 tableview[6068:907] Résiliation d'application en raison de uncaught exception 'NSInternalInconsistencyException', la raison: "tentative d'insérer la ligne 0 dans la section 0, mais il y a seulement 0 lignes dans la section 0, après la mise à jour"
** Premier lancer de pile d'appel:
(0x33e752a3 0x3bcde97f 0x33e7515d 0x3474aab7 0x35cb0a9f 0x35de6b27 0x6a10f 0x69ce5 0x33dc6037 0x346dc599 0x6b54b 0x3478c0f5 0x33e4a683 0x33e49ee9 0x33e48cb7 0x33dbbebd 0x33dbbd49 0x379702eb 0x35cd1301 0x68bdd 0x68b64)
libc++abi.dylib: mettre fin à appelé à la levée d'une exception
Le code est:
/**
The NSOperation "ParseOperation" calls addFiles: via NSNotification, on the main thread which in turn calls this method, with batches of parsed objects. The batch size is set via the kSizeOfEarthquakeBatch constant.
*/
- (void)addFilesToList:(NSArray *)files {
NSInteger startingRow = [self.fileList count];
NSLog(@"STARTING ROW:%d",startingRow);
NSInteger fileCount = [files count];
NSLog(@"FILE COUNT : %d",fileCount);
NSMutableArray *indexPaths = [[NSMutableArray alloc] initWithCapacity:fileCount];
NSLog(@"INDEX PATHS:%@",indexPaths);
for (NSInteger row = startingRow; row < (startingRow + fileCount); row++) {
NSLog(@"into for");
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
NSLog(@"INDEXPAth %@",indexPath);
[indexPaths addObject:indexPath];
}
[self.fileList addObjectsFromArray:files];
NSLog(@"ADD objects");
NSLog(@"FILELIST:%@",self.fileList);
//GETTING EXCEPTION AT THIS LINE
[self.tableview insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
}
#pragma mark - UITableViewDelegate\
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
//The number of rows is equal to the number of earthquakes in the array.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.fileList count];
NSLog(@"NUMBER OF ROWS :%d",[self.fileList count]);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *kFileCellID = @"Cell";
myTableCell *cell = (myTableCell *)[tableView dequeueReusableCellWithIdentifier:kFileCellID];
//Get the specific earthquake for this row.
fileList *file = (self.fileList)[indexPath.row];
[cell configureWithFile:file];
return cell;
}
Vous devez vous connecter pour publier un commentaire.
Dans mon cas était question, j'ai utilisé deux indexPath(indexPath,lastIndexPath). mais pour lastIndexPath.ligne de mon tableau lié.résoudre par vérifier la condition.espérons que cela aide quelqu'un.
Ce qui se passe, c'est que le tableview vous ajoutez la nouvelle cellule est toujours pas au courant des modifications apportées à l'auto.fileList tableau. L'ordre dans lequel UIKit ajoutera la nouvelle cellule et vérifiez la section de comptage est malheureusement hors de votre contrôle.
Toutefois, dans le but de résoudre ce problème UItableview insérer et supprimer des opérations doivent être enroulé sur beginsUpdate et endsUpdate méthodes appel.
J'étais mise à jour des lignes après un appel d'API.
Essayer de mettre à jour des lignes à l'intérieur de thread principal. ( comme Tous de l'INTERFACE utilisateur mise à jour doit être effectuée à l'intérieur de thread principal ).
De l'essayer....