Skip to content

Commit 1642a72

Browse files
author
Zach Drayer
committed
add collectionView:itemAtIndexPath:didMoveToIndexPath:
1 parent 789d9a2 commit 1642a72

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
@optional
2424

2525
- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath;
26+
- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath didMoveToIndexPath:(NSIndexPath *)toIndexPath;
27+
2628
- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath;
2729
- (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath canMoveToIndexPath:(NSIndexPath *)toIndexPath;
2830

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ - (void)invalidateLayoutIfNecessary {
165165
[strongSelf.collectionView deleteItemsAtIndexPaths:@[ previousIndexPath ]];
166166
[strongSelf.collectionView insertItemsAtIndexPaths:@[ newIndexPath ]];
167167
}
168-
} completion:nil];
168+
} completion:^(BOOL finished) {
169+
__strong typeof(self) strongSelf = weakSelf;
170+
if ([strongSelf.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:didMoveToIndexPath:)]) {
171+
[strongSelf.dataSource collectionView:strongSelf.collectionView itemAtIndexPath:previousIndexPath didMoveToIndexPath:newIndexPath];
172+
}
173+
}];
169174
}
170175

171176
- (void)invalidatesScrollTimer {

0 commit comments

Comments
 (0)