A deeper look at UITableView


I’m playing around with the subject and have seen something that I don’t understand.

For a UITableView with the default rowHeight of cells, we all know that 10 or 11 cells are actually allocated and used via dequeueReusableCellWithIdentifier:.

However, when one wants to set custom heights for UITableViewCells via heightForRowAtIndexPath:, the API will ask for the height of every row, every time the tableView OR an individual row, is reloaded.

Here is my question, iOS must be storing the rowHeights somewhere for use when a particular row is visible. This sounds rowBased rather than cellBased. Do you know why Apple takes this approach, rather than just calling heightForRowAtIndexPath: when the row becomes visible… much like the willDisplayCell: method?

I ask because when I update a particular visible row with a photo, I’m seeing cell height calculations for every single row, not just the visible cells. This can become very “busy”.