2011-01-05 12 views
5

He buscado y parece que no puedo encontrar ningún lugar en el desbordamiento de pila que haya tenido el mismo problema que yo. Así que uso el siguiente código:Deslizar para eliminar

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete); 
} 

y cuando swipe aparece el botón de borrar, pero cuando lo presionó no hace nada, lo he olvidado que haga?

Respuesta

10

Necesita borrar sus datos después de la declaración if. Actualmente, su declaración if no hace nada, porque simplemente tiene un punto y coma después.

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    { 
     //Code to delete data goes here. 
     //This could include removing an object from an array, deleting it from core data, 
     //and removing the selected row. 
    } 
} 
+0

aplausos, funciona como un encanto ahora –

+0

Me alegro que podría ayudar. No olvide marcar "aceptado" si todo funciona. :) – GendoIkari

+1

Sabes, podría haber resuelto esto, pero la mayoría de las veces, simplemente es más rápido mirar aquí primero. Respuesta genial y simple, y funciona de manera brillante. – PKCLsoft

Cuestiones relacionadas