Basado en samvermette's respuesta, pero modificado para usar una imagen de fondo directamente en lugar de componer una imagen de una subclase de UITableViewCell. La respuesta de Sam es buena, pero será menos eficaz que crear una imagen de fondo directamente.
Crear una subclase UIView - en este ejemplo lo llamé CustomTiledView - y agregue el código siguiente a la clase:
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"tableview_empty_cell_image"];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM (context, 1, -1);
CGContextDrawTiledImage(context,
CGRectMake(0, 0, rect.size.width, image.size.height),
[image CGImage]);
}
Agregue el código siguiente a su tableviewcontroller:
- (CGFloat)tableView:(UITableView *)tableView
heightForFooterInSection:(NSInteger)section {
// this can be any size, but it should be 1) multiple of the
// background image height so the last empty cell drawn
// is not cut off, 2) tall enough that footer cells
// cover the entire tableview height when the tableview
// is empty, 3) tall enough that pulling up on an empty
// tableview does not reveal the background.
return BACKGROUND_IMAGE_HEIGHT * 9; // create 9 empty cells
}
- (UIView *)tableView:(UITableView *)tableView
viewForFooterInSection:(NSInteger)section {
CustomTiledView *footerView = [[CustomTiledView alloc] init];
return [footerView autorelease];
}
Por último, deberá establecer el recuadro de contenido inferior de su tabla de visión negativa del valor devuelto por -tableView:heightForFooterInsection:
. En este ejemplo, sería -1*BACKGROUND_IMAGE_HEIGHT*9
. Puede establecer el recuadro de contenido inferior desde el Inspector de tamaño del Constructor de interfaz o configurando la propiedad self.tableView.contentInset
desde el controlador de vista de tabla.
¡Salud!
* * Bump obtuvo una solución que funcione? Por favor comparte aquí. Gracias – lostInTransit
Lo que he hecho hasta ahora es agregar una celda 'invisible' al final de la vista de tabla con una vista de imagen que muestra la sombra del final de la vista de tabla. Establecí el estilo de separador en ninguno. Esto crea un efecto similar, pero tendré que ajustarlo un poco más para estar contento con él. –