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

Performance of layoutAttributesForElementsInRect: is poor when UICollectionView has many thousands of cells #13

Closed
donholly opened this issue Jul 15, 2013 · 10 comments

Comments

@donholly
Copy link

This function is spending a considerable amount of time calculating the layoutAttributes during scrolling which lowers the frame rate significantly :(

@chiahsien
Copy link
Owner

Any test procedure ?

Or, could you send a pull request?

@donholly
Copy link
Author

Sure, I can do this in the next day or so!

@donholly
Copy link
Author

The general test case is:

Add 10,000+ items to the grid and try to scroll on an iphone 4 :)

@zedzhao
Copy link

zedzhao commented Sep 3, 2013

Hi, guys, any good news. I use this layout for waterfall, once there are too many pics, the performance is very bad.

@chiahsien
Copy link
Owner

Hey guys, could you try the latest commit and see if there's any improvement?

@donholly
Copy link
Author

donholly commented Sep 5, 2013

This seems to be helping quite a bit! I have noticeably less jitters now when scrolling!

Thank you very much for getting around to this.

I found one minor bug with the new implementation:

the "end" variable on line 142 could technically be larger than the number of elements in the CollectionView (causing an out of bounds exception).

I've fixed it by putting this on line 162:

end = MIN(_itemCount, end);

@donholly
Copy link
Author

donholly commented Sep 6, 2013

I'm actually seeing some issues with cell spacing now (sometimes there are large gaps between cells that don't belong there).

I'll have to look into this further, later.

I've reverted for now.

@chiahsien
Copy link
Owner

Hi, could you give the latest commit a try?

@LiDechao
Copy link

layoutAttributesForElementsInRect,this method will return a rectangle,and how this rectangle stated?

@chiahsien
Copy link
Owner

@LiDechao what's your question? maybe you should create another issue for this?

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

4 participants