Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell Reuse Identifier with Variable Height Cells

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.


1 Answers

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.

like image 119
August Avatar answered Dec 08 '25 07:12

August



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!