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

EXC_BAD_ACCESS #9

Open
esetnik opened this issue Jan 3, 2016 · 7 comments
Open

EXC_BAD_ACCESS #9

esetnik opened this issue Jan 3, 2016 · 7 comments
Labels

Comments

@esetnik
Copy link

esetnik commented Jan 3, 2016

I am getting a crash when using UICollectionViewLeftAlignedLayout on line 47. This only occurs if I set estimatedItemSize to use dynamic sizing.

NSArray *originalAttributes = [super layoutAttributesForElementsInRect:rect];

@mokagio
Copy link
Owner

mokagio commented Jan 3, 2016

Hello @esetnik, thanks for the report. I shall look into it, but cannot guarantee it is going to be soon... If you find a solution please feel free to submit a PR

@mokagio mokagio added the bug label Jan 3, 2016
@esetnik
Copy link
Author

esetnik commented Jan 3, 2016

I also filed a radar with Apple. I think this is an iOS bug because I get a
similar crash when using the superclass flow layout.
On Sun, Jan 3, 2016 at 2:53 AM Giovanni Lodi notifications@github.com
wrote:

Hello @esetnik https://github.com/esetnik, thanks for the report. I
shall look into it, but cannot guarantee it is going to be soon... If you
find a solution please feel free to submit a PR


Reply to this email directly or view it on GitHub
#9 (comment)
.

@Calvin-Huang
Copy link

@esetnik Hello! Is any update for this circumstance?
If I don't copy attribute, it would not cause EXC_BAD_ACCESS.
But xcode will told me warning said "UICollectionViewFlowLayout has cached frame mismatch".

Thanks for your help!!

@GMCoder
Copy link

GMCoder commented Dec 5, 2016

UICollectionViewLayoutAttributes* currentItemAttributes = [super layoutAttributesForItemAtIndexPath:indexPath]; delete copy fix this

@kjartandoj-fette
Copy link

kjartandoj-fette commented Jan 3, 2017

I get the same "loop" that leads to the EXC_BAD_ACCESS bug on iOS 9.3 but not on iOS 10+

If I comment out this overwritten method in UICollectionViewLeftAlignedLayout.m then it works on iOS 9 (layout is left aligned) but the layout is not left aligned on iOS 10.

- (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;
}

Anyone found a way around this for iOS 9?
Anyone knows how to at compile time exclude code based on iOS version?

screen shot 2017-01-03 at 10 07 00

@dly553709938
Copy link

Thanks GMCoder.

Reproduce:

IOS 9,
set estimatedItemSize property

petropavel13 added a commit to petropavel13/UICollectionViewLeftAlignedLayout that referenced this issue Dec 7, 2017
@michaelrevlis
Copy link

michaelrevlis commented Jan 3, 2019

iOS 9,
According to this issue, it seems that an infinite loop occurs only when estimatedItemSize is larger than final itemSize.
I set estimatedItemSize to CGSizeMake(1,1) to avoid crash.
(Updated)
Adding support for cell sizing is another solution

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

No branches or pull requests

7 participants