2009-07-23 7 views
0

J'utilise ce code ... Mais il a mis fin à ma demande quelques fois:ligne Supprimer UITableView problème

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath { 
    //FeedArray is NSMutableArray 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     [self.tableView beginUpdates]; 
     [FeedArray removeObjectAtIndex:indexPath.row]; 

     [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
     withRowAnimation:UITableViewRowAnimationFade]; 
    } 
    [self.tableView endUpdates]; 
} 

Pourquoi cela se produit? Y a-t-il un autre moyen de le faire?

Répondre

0

Je pense que [self.tableView endUpdates]; doit être dans if{} bloc

ou [self.tableView beginUpdates]; doit être avant if{}

0

je code comme cela, et il a bien fonctionné:

if (editingStyle == UITableViewCellEditingStyleDelete) 
{ 

    [self.tableView beginUpdates]; 

    //Remove the item from the array (i.e. update the data source). 
    [self.arrayList removeObjectAtIndex:indexPath.row]; 

    //Delete the row from the table. 
    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 

    [self.tableView endUpdates]; 
} 
Questions connexes