Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

heightForRowAtIndexPath being called for all rows & how many rows in a UITableView before performance issues?

I thought I had read that for a UITableView that heightForRowAtIndexPath doesn't get called on all rows, but only on the ones that will be visible. This isn't what I'm seeing however. I'm seeing hundreds of calls to heightForRowAtIndexPath for the simple situation of the orientation being changed of the iPhone for example.

So I'm assuming here therefore that for a UITableView with heightForRowAtIndexPath implemented, it does (i.e. heightForRowAtIndexPath) get called for all rows (not just the visible ones)...let me know if this isn't quite correct.

QUESTION: Given the above, how many rows in a UITableView (where heightForRowAtIndexPath is implemented) can you have before performance issues occur typically?

Is there a way around the performance issues? i.e. set a nominal/standard height for each row and not implement heightForRowAtIndexPath, but then correctly set each row height only when it is displayed and set it correctly here...but which method would one do this in?

like image 242
Greg Avatar asked Mar 16 '11 10:03

Greg


1 Answers

My goodness, I spent over an hour trying to find the source of my performance problem!

Finally I also found hundreds of calls to heightForRowAtIndexPath and a search got me this thread. THAT is really annoying. Performance goes down here already when just displaying 250 items. Thankfully the cells I want to display now all have the same size. But I could imagine someone wanting to display some different cells for a tableView with > 200 items!

FIX THIS APPLE!

Cheers

like image 95
Mario Avatar answered Sep 19 '22 14:09

Mario