¿Cómo mover una fila de tablview?
Frecuentes
Visto 135 veces
0
Estoy creando una aplicación en la que quiero mover la fila. Así que puedo hacerlo
[self.tableList setEditing:YES animado:YES];
dónde "tablaLista" es el nombre de mi tabla, pero cada vez que ejecuto esta línea. No puedo obtener el ícono para mover que generalmente viene en el lado derecho para mover una celda, en cambio, obtengo el ícono para eliminar una fila que viene en el lado izquierdo de un celda.
Por favor, ayúdame a mover mi celda y pregunta si necesitas alguna aclaración de mi pregunta..
Gracias.
3 Respuestas
1
Necesita implementar los siguientes dos métodos
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
//do code according to your requirements of app
//if you do not write ant thing in the method then also your row will be moved.
NSString *stringToMove = [[self.dataArray objectAtIndex:sourceIndexPath.row] retain];
[self.dataArray removeObjectAtIndex:sourceIndexPath.row];
[self.dataArray insertObject:stringToMove atIndex:destinationIndexPath.row];
[stringToMove release];
[tableView reloadData];
}
contestado el 03 de mayo de 12 a las 11:05
0
use este enlace de Apple y desplácese hacia abajo para Apple cómo mover o desplazarse por las filas. alegría :)
– beginUpdates – endUpdates – insertRowsAtIndexPaths:withRowAnimation: – deleteRowsAtIndexPaths:withRowAnimation: – moveRowAtIndexPath:toIndexPath: – insertSections:withRowAnimation: – deleteSections:withRowAnimation: – moveSection:toSection:
– scrollToRowAtIndexPath:atScrollPosition:animado: – scrollToNearestSelectedRowAtScrollPosition:animado:
contestado el 03 de mayo de 12 a las 11:05
0
use estos dos métodos para mover filas
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath*)indexPath
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
contestado el 03 de mayo de 12 a las 11:05
ok, bienvenido, amigo, si es útil para usted, marque el signo correcto y la flecha hacia arriba en mi respuesta para que sea útil para otras gracias. - vishifono
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas iphone or haz tu propia pregunta.
¿Encontraste solución a tu ans? - Saad
puede mostrarnos una captura de pantalla de su salida. o si no, ¿puedes ampliar tu pregunta un poco más? - sandy
use el estilo de edición y lea el enlace para obtener más detalles - Saad
No hay problema... Recibí la respuesta Gracias.... - vshall