DraggableCollectionView icon indicating copy to clipboard operation
DraggableCollectionView copied to clipboard

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

Open TheCoordinator opened this issue 12 years ago • 4 comments

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.

TheCoordinator avatar Sep 17 '13 13:09 TheCoordinator

I also have this problem

bentech avatar Oct 01 '13 14:10 bentech

Try this:


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

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

    return YES;
}

wiruzx avatar Mar 19 '14 15:03 wiruzx

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

alessandro-martin avatar Nov 22 '14 18:11 alessandro-martin

@wiruzx Thanks wiruzx, It was a tremendous help.

hachinobu avatar Apr 05 '15 06:04 hachinobu