views:

1497

answers:

2

I'd like to change the height of a UITableViewCell when it gets selected. I'm able to do this by defining

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

and calling the tableview's reloadData when the cell gets selected, but I'd like to have the change be animated. Any suggestions on how to go about this?

A: 

Try calling reloadData in an animation block after you have set parameters that will force a new height?

Kendall Helmstetter Gelner
I tried this, didn't work, although I guess it could've depending on what happens in reloadData
+1  A: 

You can find a discussion of this here on SO:

http://stackoverflow.com/questions/460014/can-you-animate-a-height-change-on-a-uitableviewcell-when-selected

Corey Floyd
thanks, hadn't seen that. The trick of adding and removing the changed row seems to work pretty well. In fact, my heightForRowAtIndexPath method gets called for every row just by doing: [tableView beginUpdates]; [tableView endUpdates];