2011-12-28 21 views
8

Hola tengo vista de tabla con muchos objetos en ella. Si quiero agregar una fila en ella sin volver a cargar toda la tabla. Porque hay algún proceso en la celda. ¿Alguien puede ayudar?Insertar fila sin volver a cargar la tabla

+2

Código de ejemplo: http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Listings/ReadMe_txt.html –

Respuesta

12

Puede hacerlo de 2 maneras -

[tableView beginUpdates]; 
[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone]; 
[tableView endUpdates]; 

o

[tableView insertRowsAtIndexPaths:newResults withRowAnimation:UITableViewRowAnimationNone]; 

aquí newResults son una NSArray de NSIndexPath que se necesita para crear. Luego, las nuevas filas se insertan (con alguna animación o sin) en esas filas.

+0

hombre THX, su trabajo – user1072740

+0

¿Por qué ¿Estás utilizando 'withRowAnimation: UITableViewRowAnimationNone' en ambos ejemplos? – Gomfucius

2

Uso debajo del método delegado

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 
Cuestiones relacionadas