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

Breaks down if using variable height cell #11

Open
ssfking opened this issue Mar 25, 2014 · 2 comments
Open

Breaks down if using variable height cell #11

ssfking opened this issue Mar 25, 2014 · 2 comments

Comments

@ssfking
Copy link

ssfking commented Mar 25, 2014

Gets super laggy if using variable sized (height) cell, which is pretty common. Seems like PrepareLayout keeps getting called on scrolling, which in turn tries to find the height for EACH one of the 10000 cells...

  • (CGSize)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"height for row:%i", indexPath.row);
    return CGSizeMake(self.view.frame.size.width, 44);
    }
@atomkirk
Copy link

atomkirk commented May 7, 2014

You have to cache the sizes yourself. Here's how I did it:

Then it's super smooth. Just clear the cache before you reload the collection view or insert/delete cells.

@njam
Copy link

njam commented May 13, 2014

Experienced a similar problem: basically as soon as we've implemented sizeForItemAtIndexPath the UI would become laggy with many elements (50'000+).
It doesn't matter what the implementation looks like though, even if we return a reference to always the same "size" the performance would degrade. If I remove the implementation then performance is good again.
cc @fresswolf

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

3 participants