Open lukescott opened 11 years ago
Hi, I'm running into this issue and it looks like you can simply avoid it by setting maximumNumberOfTouches on _panPressGestureRecognizer to 1 in LSCollectionViewHelper::initWithCollectionView. You just have to define the property as a UIPanGestureRecognizer (instead of a UIGestureRecognizer) in the header file. Looking at the odd behaviour we get when using multi touch this might be the simplest solution, unless there's a benefit to having multi touch enabled?
Hi, I'm using this on xcode-5, but not able to set maximumNumberOfTouches on _panPressGestureRecognizer to 1in LSCollectionViewHelper. I set multiple touch to no on my cell and collection view but still it causes crash.
Is there any other way to avoid this crash...? Thanks in advance.
gouravgupta72,
I found out the problem why you can't set maximumNumberOfTouches
.
In LSCollectionViewHelper
's initWithCollectionView
, you have this:
_panPressGestureRecognizer = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(handlePanGesture:)];
_panPressGestureRecognizer.delegate = self;
However, if you check the LSCollectionViewHelper.h file, you'll see panPressGestureRecognizer
is declared as:
@property (nonatomic, readonly) UIGestureRecognizer *panPressGestureRecognizer;
I simply changed this to:
@property (nonatomic, readonly) UIPanGestureRecognizer *panPressGestureRecognizer;
Then I'm able to set:
_panPressGestureRecognizer.maximumNumberOfTouches = 1;
Not sure what effect this has on the draggable collection view library but it seems to fix the two finger crash for me too.
Just add below code snippet in LSCollectioViewHelper and you are done.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if (gestureRecognizer.numberOfTouches < 1) {
return YES;
} else {
return NO;
}
}
If you hold your finger on one cell, then place a finger on the other the center of the two fingers is used (different issue). When you lift the first finger it crashes with:
*\ Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items before section 2147483647 when there are only 5 sections in the collection view'
I suspect it might have something to do with a
numberOfItemsInSection
call somewhere, but I'm going to have to do some more debugging to find out.