Pregunta

Tengo una vista que tiene su propia barra de navegación y una vista de tabla. Quiero editar & amp; eliminar elemento en esa vista de tabla. He colocado y el botón de edición en la barra de navegación como este.

self.navItem.leftBarButtonItem = self.editButtonItem;

Y también tiene un método como este.

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if(editingStyle == UITableViewCellEditingStyleDelete) {

        //Get the object to delete from the array.
        //Delete the object from the table.
        [self.tblView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
}

Pero cuando hago clic en ese botón, ninguno de los elementos en la vista de tabla gira con ese icono de marca roja. Solo el título del botón de edición cambia a " Listo " ;.

¿Cuál debería ser el problema?

¿Fue útil?

Solución

¿Es este un UIViewController, o un UITableViewController? Parecería (desde self.tblView en el código adjunto) que está utilizando un UIViewController estándar. En este caso, debe implementar setEditing: animated: en su controlador de vista, que, a su vez, debería llamar a eso en su vista de tabla.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top