Domanda

Ho semplicemente cerco di eliminare una riga da un UITableView con il seguente codice:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (editingStyle == UITableViewCellEditingStyleDelete)
     {
         [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
     }
}

Il problema è che i miei crash app. (GDB: programma ha ricevuto il segnale:. "EXC_BAD_INSTRUCTION") Qualcuno sa perché?

È stato utile?

Soluzione

Probabilmente È necessario modificare il numero restituito in

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section

per il indexPath.section di essere uno inferiore rispetto a prima della cancellazione.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top