Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

LongPress on an empty area of the collectionView causes the app to crash #25

Open
TheCoordinator opened this issue Sep 17, 2013 · 4 comments

Comments

@TheCoordinator
Copy link

If the long press is not happening on the cell but on the empty space of the UICollectionView, it causes an NSRangeException.

You can reproduce the bug from the FlowLayoutDemo app.

@bentech
Copy link

bentech commented Oct 1, 2013

I also have this problem

@wiruzx
Copy link

wiruzx commented Mar 19, 2014

Try this:

- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row >= [self.items[indexPath.section] count]) {
        return NO;
    }

    return YES;
}

@alessandro-martin
Copy link

Thanks wiruzx, that solved the problem. It also prevents from selecting a nearby cell if touching empty space which is (usually) the desirable behaviour.

@hachinobu
Copy link

@wiruzx Thanks wiruzx, It was a tremendous help.

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

No branches or pull requests

5 participants