UITableViewCell reusable identifier with variable height cells

I have five different cells in the table in five sections, differing only in height and text. Should I have one reuse identifier or five? I am using a custom cell.

An Apple document talks about reuse with a cell having the "same general" configuration. Different heights make each one different for caching and reuse. I can use different fonts, but the rest of the material between the cells is the same, color, etc.

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

Since my device seems already hot while my application is running, I just want to make sure that I am doing this efficiently. I want to reuse the cache and cells in the table, as well as when reloading the table with new data.

Would thank for some suggestions.

+3
source share
1 answer

You may have one reusable identifier, but to change the height you will need to implement the UITableViewDelegate method:

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

However, I cannot imagine that one cell has 44 pixels high and the other 70 pixels, as having a common configuration. If they differ in height, they are likely to differ in content, and this will require different reuse identifiers.

+2

Source: https://habr.com/ru/post/1704816/


All Articles