2011-09-08 5 views
0

J'ai un problème avec ma suppression de cellules dans le tableau, mon programme se bloque simplement lorsque j'appuie sur le bouton Supprimer.supprimer des cellules dans la table Voir

Voici mon code pour elle:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     // Delete the managed object at the given index path 
     sect = [listArray objectAtIndex:indexPath.row]; 
     [sect removeObjectAtIndex:indexPath.row]; 

     // Update Event objects array and table view 
     [listArray removeObjectAtIndex:indexPath.row]; 
     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; 
     tableView.editing = YES; 

     } 
} 
+1

se bloque avec quoi? EXC_BAD_ACCESS ou l'index de tableau SIGABRT hors limites ou quoi? – 0x8badf00d

+0

Publiez la sortie de votre journal de panne. – WrightsCS

+0

thx, problème résolu – John2

Répondre

-1

complètement supprimer les éléments suivants:

sect = [listArray objectAtIndex:indexPath.row]; 
[sect removeObjectAtIndex:indexPath.row]; 

et

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; 

Il suffit d'appeler [listArray removeObjectAtIndex:indexPath.row]; puis appelez reloadData pour vous rafraîchir UITableView.

Questions connexes