diff --git a/CHANGELOG.md b/CHANGELOG.md index 53ae274b7b..c3812f80b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## master * Add your own contributions to the next release on the line below this with your name. +- [ASCollectionView] Fix reording of cells manually for iOS 9 & 10. [Max Wang](https://github.com/wsdwsd0829). [#1081](https://github.com/TextureGroup/Texture/pull/1081) - [ASDisplayNode] Allow add/remove interface state delegates on background thread. [Max Wang](https://github.com/wsdwsd0829). [#1090](https://github.com/TextureGroup/Texture/pull/1090) - [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses).[Scott Goodson](https://github.com/appleguy) [#1077](https://github.com/TextureGroup/Texture/pull/1077) - [ASNetworkImageNode] Allow delegate methods to be called on background thread. [Max Wang](https://github.com/wsdwsd0829). [#1007](https://github.com/TextureGroup/Texture/pull/1007) diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index 47ea99bf0b..69cd531478 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -139,6 +139,12 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; * (0 sections) we always check at least once after each update (initial reload is the first update.) */ BOOL _hasEverCheckedForBatchFetchingDueToUpdate; + + /** + * Set during beginInteractiveMovementForItemAtIndexPath and UIGestureRecognizerStateEnded + * (or UIGestureRecognizerStateFailed, UIGestureRecognizerStateCancelled. + */ + BOOL _reordering; /** * Counter used to keep track of nested batch updates. @@ -1013,9 +1019,29 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; - (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath { ASDisplayNodeAssertMainThread(); - [self performBatchUpdates:^{ - [_changeSet moveItemAtIndexPath:indexPath toIndexPath:newIndexPath animationOptions:kASCollectionViewAnimationNone]; - } completion:nil]; + if (!_reordering) { + [self performBatchUpdates:^{ + [_changeSet moveItemAtIndexPath:indexPath toIndexPath:newIndexPath animationOptions:kASCollectionViewAnimationNone]; + } completion:nil]; + } else { + [super moveItemAtIndexPath:indexPath toIndexPath:newIndexPath]; + } +} + +- (BOOL)beginInteractiveMovementForItemAtIndexPath:(NSIndexPath *)indexPath { + BOOL success = [super beginInteractiveMovementForItemAtIndexPath:indexPath]; + _reordering = success; + return success; +} + +- (void)endInteractiveMovement { + _reordering = NO; + [super endInteractiveMovement]; +} + +- (void)cancelInteractiveMovement { + _reordering = NO; + [super cancelInteractiveMovement]; } #pragma mark -