hey, Podría alguien guiarme a través de esto Tengo alrededor de 15 entradas en la tabla Me gustaría que otras 15 subieran con la carga más en la última UITableViewCell. ¿Alguien podría ayudarme?haciendo un botón "cargar más" en uitableviewcell?
Respuesta
para mostrar una fila adicional en el tableview, en
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return dataRows+1;
}
En
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//after setting tableviewcell
if(indexPath.row==dataRows){
[email protected]"Load More Rows";
}
}
En
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==dataRows){
//there you can write code to get next rows
}
}
Es necesario actualizar los numberOfRows variable en función de las filas que se muestran.
Editar: Después de obtener las entradas adicionales, puede agregarlas a la matriz de entradas existentes utilizando el siguiente método. Su matriz original debe ser NSMutableArray
para usar este método.
[originalEntriesArray addObjectsFromArray:extraEntriesArray];
@SriPriya, Agregar esto línea 'numberOfRows = [yourEntriesArray count] + 1;' para hacerlo más claro. – EmptyStack
@Simon: hola ..., actualicé el código – SriPriya
@SriPriya, Hmmm :) – EmptyStack
esperanza esto ayuda
Me tomó una serie mutable y una variable entera y establezca el recuento total de la matriz a la variable entera
arr = [[NSMutableArray alloc]initWithObjects:@"Radix",@"Riki", nil]; dataRows = [arr count];
y luego me puse el número de filas en las secciones según la variable entera en el método de fuente de datos de la tabla
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return dataRows+1; }
porque quería una celda extra al final.
Ahora es el momento para ajustar el texto de la celda de la tabla
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ NSString estática * CellIdentifier = @ "Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
//setting the text of the cell as per Mutable array
if (indexPath.row < [arr count]) {
cell.textLabel.text = [arr objectAtIndex:indexPath.row];
}
//setting the text of the extra cell
if (indexPath.row == dataRows) {
cell.textLabel.text = @"more cells";
}
return cell;
}
ahora en el éxito de la célula más celdas que desee células adicionales a la derecha por lo que acaba de añadir su código dentro del método
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
, significa que tiene que hacer algo como esto
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row == dataRows) { //code for exra cells please } }
Ejecute su aplicación para verificar este código.
Escribí un proyecto de ejemplo que hace justamente esto. Puedes descargarlo desde GitHub https://github.com/Abizern/PartialTable
Me gusta la parte de actualizar tableView usando 'beginUpdate' y' endUpdate' –
escribí algo que podría ser útil: https://github.com/nmondollot/NMPaginator
Se encapsula la paginación, y funciona con casi cualquier servicio web utilizando la página y los parámetros per_page. También presenta una UITableView con búsqueda automática de los próximos resultados a medida que se desplaza hacia abajo.
- 1. Botón Agregar a UITableViewCell
- 2. Incrementar un número haciendo clic en un botón
- 3. Volver a cargar la página cuando se visita haciendo clic en el botón Atrás en Firefox
- 4. UIButton en UITableViewCell
- 5. Java Abrir una nueva ventana haciendo clic en un botón
- 6. Haciendo clic en el botón cancelar showInputDialogue
- 7. ¿Cómo aceptar una llamada entrante haciendo clic en un botón?
- 8. Haciendo un botón con gráficos vectoriales en el contenido
- 9. ¿Hay un complemento de desplazamiento infinito con un botón de cargar más?
- 10. UITextField en un UITableViewCell
- 11. Haciendo un botón personalizado usando UIView o reemplazando UIButton?
- 12. Haciendo t: trabajo commandButton como h: Botón
- 13. Cargar más funciones en Javascript
- 14. Haciendo botón de retroceso de vista raíz en UINavigationController
- 15. Haciendo que se aprecie un botón de cacao, programáticamente
- 16. Llamar a un método haciendo clic en un botón en un UIWebView
- 17. Recuperar un marco UITableViewCell
- 18. Google más un error de botón
- 19. Cómo deshabilitar un botón más elegante
- 20. Usando una imagen personalizada para un accesorioView de UITableViewCell y haciendo que responda a UITableViewDelegate
- 21. Cómo detectar si el botón eliminar UItableviewcell estaba oculto?
- 22. Vim: Haciendo la autocompletación más inteligente
- 23. Copiando UITableViewCell
- 24. Objetivo c: la mejor práctica para manejar un evento táctil de botón para un botón de una UITableViewCell personalizada
- 25. Haciendo que Zend-Framework funcione más rápido
- 26. Cómo implementar "Cargar 25 más" en UITableViewController
- 27. ¿Cómo implementar "Cargar más registros" en TableView en iPhone SDK?
- 28. Resize UIImageView en UITableViewCell
- 29. deshabilitar zoom arrastrando en Google maps haciendo clic en un botón
- 30. Haciendo clic en un botón de la GUI en Java Swing
posible duplicado de ["Cargar más" en UITableView] (http://stackoverflow.com/questions/4410257/) o [Cómo implementar "Cargar 25 más"] (http://stackoverflow.com/questions/ 2801069 /) o [Aplicación de correo cargar más mensajes] (http://stackoverflow.com/questions/4396464/) o [Cargar más registros en iPhone] (http://stackoverflow.com/questions/4965919/) o [Agregar cargar más opciones a la vista de tabla] (http://stackoverflow.com/questions/5898399/) entre [otros] (http://stackoverflow.com/search?q=iphone+load+more) –