Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load large number of data, performance problem. #19

Closed
btxkenshin opened this issue Mar 26, 2015 · 2 comments
Closed

Load large number of data, performance problem. #19

btxkenshin opened this issue Mar 26, 2015 · 2 comments

Comments

@btxkenshin
Copy link

First ,the sample is so beautiful and helpful.And i used this in my project for months.
But recently i have got some performance problem:
Here is the conditions:

  1. large data of datasource which mins there are large number of rows, and need to load the same.For example 100 rows one time.
  2. complicate layoutconstraint of cell it self

The result:
in iOS7,as you know reload tableview will cause to caculate height of all cells one time(on main thread),which take about 2 seconds in my project. Need to fix this.

I have tried to use (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(7_0); ,but it seems to be some bug itself in iOS7.

Need help.
I will update this if i figure out.

Thanks

@smileyborg
Copy link
Owner

Hi @btxkenshin,

When you have a large number of rows in your table view, you must implement row height estimation in order to prevent the table view from asking for the row height for each cell at first load. There are some bugs with row height estimation, but they aren't that bad compared to not using it!

I recommend simply setting tableView.estimatedRowHeight = 44.0;, where 44.0 should be your "average" cell size.

That's pretty much all you need to do. If for some reason you really don't want to use row height estimation, then you are out of luck, and will need to avoid using auto layout to size your cells.

@btxkenshin
Copy link
Author

@smileyborg That's exactly what i did after some search and try,which worked well.
Thanks
And i also go futher,to cache the cellheight for each row,simply in the data model.
And am also thinking if i could do the row caculate in the background thread, after i get the data model from server.cache the height and when tableview reload, first read it. if not found ,do the caculate right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants