From 9eb7d81ff724d8ab013533998d49b83026a94eea Mon Sep 17 00:00:00 2001 From: Jason Bodie Date: Tue, 26 Jul 2016 11:14:10 -0700 Subject: [PATCH 1/5] handle case where input might not be found and app crashes --- DraggableCollectionView/Helpers/LSCollectionViewHelper.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m index 034c360..97184df 100644 --- a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m +++ b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m @@ -321,7 +321,8 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)sender - (void)warpToIndexPath:(NSIndexPath *)indexPath { - if(indexPath == nil || [lastIndexPath isEqual:indexPath]) { + if(indexPath == nil || indexPath.row == NSNotFound || [lastIndexPath isEqual:indexPath]) + { return; } lastIndexPath = indexPath; From 4a7b7c7b0c1c73d8c95daeb63c8fe40e2dadcfd7 Mon Sep 17 00:00:00 2001 From: Jason Bodie Date: Thu, 8 Sep 2016 11:14:22 -0700 Subject: [PATCH 2/5] guarding for support of ios 10 drag and drop --- .../Helpers/LSCollectionViewHelper.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m index 97184df..1771fed 100644 --- a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m +++ b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m @@ -70,13 +70,14 @@ - (id)initWithCollectionView:(UICollectionView *)collectionView initWithTarget:self action:@selector(handlePanGesture:)]; _panPressGestureRecognizer.delegate = self; [_collectionView addGestureRecognizer:_panPressGestureRecognizer]; - - for (UIGestureRecognizer *gestureRecognizer in _collectionView.gestureRecognizers) { - if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) { - [gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer]; - break; - } - } + +# iOS 10 comment out to support drag and drop +# for (UIGestureRecognizer *gestureRecognizer in _collectionView.gestureRecognizers) { +# if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) { +# [gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer]; +# break; +# } +# } [self layoutChanged]; } From 69d3235f725a4c49b321fd8ccf2c581d0fc1143f Mon Sep 17 00:00:00 2001 From: Jason Bodie Date: Thu, 8 Sep 2016 11:23:06 -0700 Subject: [PATCH 3/5] attempt at fixing the positioning issue --- DraggableCollectionView/Helpers/LSCollectionViewHelper.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m index 1771fed..c9510bc 100644 --- a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m +++ b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m @@ -322,7 +322,9 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)sender - (void)warpToIndexPath:(NSIndexPath *)indexPath { - if(indexPath == nil || indexPath.row == NSNotFound || [lastIndexPath isEqual:indexPath]) + if( indexPath == nil + || [ lastIndexPath isEqual: indexPath ] + || indexPath.item > [ self.collectionView numberOfItemsInSection: indexPath.section ] - 1 ) { return; } From 90a4ea913a9231475327fb5d30df3e3f1d6b06ef Mon Sep 17 00:00:00 2001 From: Jason Bodie Date: Thu, 8 Sep 2016 11:28:56 -0700 Subject: [PATCH 4/5] reving the podspec --- DraggableCollectionView.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DraggableCollectionView.podspec b/DraggableCollectionView.podspec index 2ed2567..eda312d 100644 --- a/DraggableCollectionView.podspec +++ b/DraggableCollectionView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "DraggableCollectionView" - s.version = "0.1.3" + s.version = "0.1.4" s.summary = "Extension for the UICollectionView and UICollectionViewLayout that allows a user to move items with drag and drop." s.homepage = "https://github.com/lognllc/DraggableCollectionView" s.license = { :type => 'MIT', :file => 'LICENSE' } From cb245fd45eb6eae8de91c6ef7dd7856d0860b73f Mon Sep 17 00:00:00 2001 From: Jason Bodie Date: Thu, 8 Sep 2016 11:40:28 -0700 Subject: [PATCH 5/5] oops ARGH --- .../Helpers/LSCollectionViewHelper.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m index c9510bc..9f1d9da 100644 --- a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m +++ b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m @@ -71,13 +71,13 @@ - (id)initWithCollectionView:(UICollectionView *)collectionView _panPressGestureRecognizer.delegate = self; [_collectionView addGestureRecognizer:_panPressGestureRecognizer]; -# iOS 10 comment out to support drag and drop -# for (UIGestureRecognizer *gestureRecognizer in _collectionView.gestureRecognizers) { -# if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) { -# [gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer]; -# break; -# } -# } +// iOS 10 comment out to support drag and drop +// for (UIGestureRecognizer *gestureRecognizer in _collectionView.gestureRecognizers) { +// if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) { +// [gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer]; +// break; +// } +// } [self layoutChanged]; }