How can I increase the height of UITableViewCell dynamiclly

cocoa-touch, iphone, uitableview

Solution

- Store selected index in your controller.

Return cell's height depending on that index:

CGFloat height = 30.0f;
...
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return indexPath.row == selectedIndex ? height+100 : height;
}

Refresh tableview geometry in `didSelectRowAtIndexPath` method (empty block between `beginUpdates` and `endUpdates` does the trick):

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    index = indexPath.row;
    [tableView beginUpdates];
    [tableView endUpdates];      
}

Problem

I have an UITableView which includes a list of UITableViewCells. And I set the heights of UITableViewCells in method `(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath`. However, I need to increase the height of `UITableViewCell` when it is selected. For example, the height of `UITableViewCell` needs to increase 100 pixels when the cell is selected, does anyone know how to do it?

Original source