views:

1032

answers:

1

I have five different cells in a table across five sections differing just in height, and text. Will I need to have one reuse identifier or five ? I am using a custom cell.

The Apple document talks about reuse with cell having the "same general" configuration. Does differing height make each different for caching and reuse perspectives. I may use differing fonts but the rest of the stuff between cells is the same, color etc.

When I pop this table and push a new one the new table cell again will differ in height based on the amount of text content in the new row selection.

Since my device seems already getting hot while running my app just want to make sure I do this efficiently. I want to reuse the cache and cells within the table as well as when reloading table with new data.

Would appreciate some suggestions.

+2  A: 

You can have a single re-use identifier, but to change the height you'll have to implement the UITableViewDelegate method:

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

That said, I can't imagine one cell that's 44 pixels high and another that's 70 pixels high as having the "same general" configuration. If they're that different in height, they're probably going to be that different in contents, and that would require different re-use identifiers.

August
I'm looking to do this, and the only difference is that some cells have taller images than others so there is a case where variable height would work for the same reuse identifier.
Kevlar
*If they're that different in height, they're probably going to be that different in contents, and that would require different re-use identifiers.* Not so much actually. The memory overhead comes from having to create and destroy objects like Labels, TextViews, and Buttons. If you're just changing sizes but keeping the same general layout (ie: same objects), it should be fine and work better to reuse cells.
Michael Grinich