lukescott / DraggableCollectionView

Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop. --- HELP WANTED --- Looking for maintainer and help with the experimental branch.
MIT License
549 stars 175 forks source link

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

Open TheCoordinator opened 11 years ago

TheCoordinator commented 11 years ago

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 commented 11 years ago

I also have this problem

wiruzx commented 10 years ago

Try this:


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

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

    return YES;
}
alessandro-martin commented 10 years ago

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 commented 9 years ago

@wiruzx Thanks wiruzx, It was a tremendous help.