ios - Expandir la celda de vista de tabla como la aplicación de Twitter
Quiero tener el mismo comportamiento que la aplicación de Twitter al seleccionar un tweet que es: expandir la fila y agregar contenido complementario.
Así que esto no es solo un tamaño de fila básico. Creo que necesito 2 celdas personalizadas diferentes, así que hice algo como eso:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath compare:self.selectedIndexPath] != NSOrderedSame) {
FirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FirstCell"];
if (!cell) {
cell = [[FirstCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FirstCell"];
}
cell.firstnameLabel.text = [[self.items objectAtIndex:indexPath.row] objectForKey:@"firstname"];
return cell;
}
else {
SecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SecondCell"];
if (!cell) {
cell = [[SecondCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SecondCell"];
}
cell.firstnameLabel.text = [[self.items objectAtIndex:indexPath.row] objectForKey:@"firstname"];
cell.lastnameLabel.text = [[self.items objectAtIndex:indexPath.row] objectForKey:@"lastname"];
return cell;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath compare:self.selectedIndexPath] == NSOrderedSame) {
return 80.0;
} else {
return 44.0;
}
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.selectedIndexPath = indexPath;
[tableView reloadData];
}
Mi problema aquí es que quiero mantener una animación fluida como la aplicación de Twitter, que no es mi caso debido a[tableView reloadData]
(lo cual es obligatorio, creo, ya que tengo 2 celdas personalizadas diferentes).
¿Alguien sabe una solución a mi necesidad o tal vez alguien sabe cómo la aplicación de Twitter maneja estas cosas de animación?