mokagio / UICollectionViewLeftAlignedLayout

A layout for UICollectionView that aligns the cells to the left.
MIT License
1.29k stars 178 forks source link

Fix cached frame mismatch warning (issue #4) #5

Closed nuudles closed 8 years ago

nkhoshini commented 8 years ago

:+1: I was running into this too, nice fix!

Here's a simplified version of the layoutAttributesForElementsInRect method, it avoids having to do multiple copies for the attributes and leverages the copied object from layoutAttributesForItemAtIndexPath.

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *originalAttributes = [super layoutAttributesForElementsInRect:rect];
    NSMutableArray *updatedAttributes = [NSMutableArray arrayWithArray:originalAttributes];
    for (UICollectionViewLayoutAttributes *attributes in originalAttributes) {
        if (!attributes.representedElementKind) {
            NSUInteger index = [updatedAttributes indexOfObject:attributes];
            updatedAttributes[index] = [self layoutAttributesForItemAtIndexPath:attributes.indexPath];
        }
    }

    return updatedAttributes;
}
jvenegask commented 8 years ago

my code is: captura de pantalla 2015-09-30 a las 6 01 25 p m

i change for: captura de pantalla 2015-09-30 a las 6 11 42 p m

but not fix the problem! (my code is good for iphone 4s, 5s but not for iphone 6 and 6+, with ios 9)

what is broke? help me! thanks very much

tlandsman commented 8 years ago

YAY! Thanks so much for the pods update with the fix! You rock!