rjg
rjg

Reputation: 105

UITableViewCell - Update tableview layout

I have a tableviewcell, that on tap, grows in size, height wise, by updating the frame.

The problem is, the cells below don't adjust, move down to make it visible underneath, and the select row events are still based on the old sizes, before tap. I am using Facebook POP - which is handling animation, so tableview.beginUpdates() is out of the question, maybe?

Upvotes: 0

Views: 1788

Answers (2)

Holly
Holly

Reputation: 5290

You cannot manually update the frame of a UITableViewCell by changing its frame or bounds. Instead, you need to change the value returned by -tableView:heightForRowAtIndexPath: for that indexPath and then perform:

[self.tableView beginUpdates];
[self.tableView endUpdates];

This will cause the tableView to recalculate the heights of all the rows.

Upvotes: 1

Jesper Schläger
Jesper Schläger

Reputation: 375

First, you need to make sure that you return the new height in heightForRowAtIndexPath, then you need to make the tableview update the cell. If you don't care about animation just call [tableview reloadData]. If you want animation you need to call [tableview reloadRowAtIndexPath: indexpath_of_your_cell]

Upvotes: 0

Related Questions