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

UICollectionViewFlowLayout warning #97

Open
ianiv opened this issue Nov 26, 2015 · 1 comment
Open

UICollectionViewFlowLayout warning #97

ianiv opened this issue Nov 26, 2015 · 1 comment

Comments

@ianiv
Copy link

ianiv commented Nov 26, 2015

The first time a letter is typed, the following warning is printed to the console:

Logging only once for UICollectionViewFlowLayout cache mismatched frame
UICollectionViewFlowLayout has cached frame mismatch for index path <NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1} - cached value: {{54, 0}, {311, 31}}; expected value: {{59, 0}, {50, 31}}
This is likely occurring because the flow layout subclass MBContactCollectionViewFlowLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

Making a copy of the attributes returned by layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath solves the problem.

@tcheard
Copy link

tcheard commented Feb 17, 2016

Changing MBContactCollectionViewFlowLayout.m:21 from
NSArray* attributesToReturn = [super layoutAttributesForElementsInRect:rect];
to
NSArray* attributesToReturn = [[NSArray alloc] initWithArray:[super layoutAttributesForElementsInRect:rect] copyItems:YES];

and

MBContactCollectionViewFlowLayout.m:37 from
UICollectionViewLayoutAttributes* currentItemAttributes = [super layoutAttributesForItemAtIndexPath:indexPath];
to
UICollectionViewLayoutAttributes* currentItemAttributes = [[super layoutAttributesForItemAtIndexPath:indexPath] copy];

fixes the warnings for me.

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