Almost every time I write an application for a client, I have to implement some kind of βhackβ in order to get UITableViewCellin order to dynamically become the right height. Depending on the content of cells, this may vary depending on complexity.
I usually end up with code that formats the cell twice, once in heightForRowAtIndexPath:, and then back in cellForRowAtIndexPath:. Then I use an array or dictionary to store the height or formatted cell object.
I probably wrote and rewrote this code 20 times in the last 2 years. Why did Apple implement it in that order? It would be much simpler to adjust the cells, and THEN to set the height either at cellForRowAtIndexPath:or soon after heightForRowAtIndexPath:.
Is there a good reason for the existing order? Is there a better way to handle this?
source
share