Skip to content

Commit 07a7a1b

Browse files
committed
- Fix some protocol naming and calling to conforms more towards Apple convention.
1 parent f37c1bb commit 07a7a1b

5 files changed

Lines changed: 24 additions & 23 deletions

File tree

LXRCVFL Example using Storyboard/LXRCVFL Example using Storyboard/LXCollectionViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <UIKit/UIKit.h>
1010
#import "LXReorderableCollectionViewFlowLayout.h"
1111

12-
@interface LXCollectionViewController : UICollectionViewController <UICollectionViewDataSource, LXReorderableCollectionViewDatasource>
12+
@interface LXCollectionViewController : UICollectionViewController <LXReorderableCollectionViewDatasource, LXReorderableCollectionViewDelegateFlowLayout>
1313

1414
@property (strong, nonatomic) NSMutableArray *deck;
1515

LXRCVFL Example using Storyboard/LXRCVFL Example using Storyboard/LXCollectionViewController.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
7878
return playingCardCell;
7979
}
8080

81-
#pragma mark - LXReorderableCollectionViewDataSource methods
81+
#pragma mark - LXReorderableCollectionViewDatasource methods
8282

8383
- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath {
8484
PlayingCard *playingCard = [self.deck objectAtIndex:fromIndexPath.item];
@@ -120,21 +120,21 @@ - (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSInd
120120
#endif
121121
}
122122

123-
#pragma mark - LXReorderableCollectionViewDelegate methods
123+
#pragma mark - LXReorderableCollectionViewDelegateFlowLayout methods
124124

125-
- (void)collectionView:(UICollectionView *)collectionView willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
125+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
126126
NSLog(@"will begin drag");
127127
}
128128

129-
- (void)collectionView:(UICollectionView *)collectionView didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
129+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
130130
NSLog(@"did begin drag");
131131
}
132132

133-
- (void)collectionView:(UICollectionView *)collectionView willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
133+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
134134
NSLog(@"will end drag");
135135
}
136136

137-
- (void)collectionView:(UICollectionView *)collectionView didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
137+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath {
138138
NSLog(@"did end drag");
139139
}
140140

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
@protocol LXReorderableCollectionViewDelegateFlowLayout <UICollectionViewDelegateFlowLayout>
3333
@optional
3434

35-
- (void)collectionView:(UICollectionView *)collectionView willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
36-
- (void)collectionView:(UICollectionView *)collectionView didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
37-
- (void)collectionView:(UICollectionView *)collectionView willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
38-
- (void)collectionView:(UICollectionView *)collectionView didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
35+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
36+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
37+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
38+
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
3939

4040
@end

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
254254

255255
self.selectedItemIndexPath = currentIndexPath;
256256

257-
if ([self.delegate respondsToSelector:@selector(collectionView:willBeginDraggingItemAtIndexPath:)]) {
258-
[self.delegate collectionView:self.collectionView willBeginDraggingItemAtIndexPath:self.selectedItemIndexPath];
257+
if ([self.delegate respondsToSelector:@selector(collectionView:layout:willBeginDraggingItemAtIndexPath:)]) {
258+
[self.delegate collectionView:self.collectionView layout:self willBeginDraggingItemAtIndexPath:self.selectedItemIndexPath];
259259
}
260260

261261
UICollectionViewCell *collectionViewCell = [self.collectionView cellForItemAtIndexPath:self.selectedItemIndexPath];
@@ -296,8 +296,8 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
296296
if (strongSelf) {
297297
[highlightedImageView removeFromSuperview];
298298

299-
if ([strongSelf.delegate respondsToSelector:@selector(collectionView:didBeginDraggingItemAtIndexPath:)]) {
300-
[strongSelf.delegate collectionView:strongSelf.collectionView didBeginDraggingItemAtIndexPath:strongSelf.selectedItemIndexPath];
299+
if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didBeginDraggingItemAtIndexPath:)]) {
300+
[strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didBeginDraggingItemAtIndexPath:strongSelf.selectedItemIndexPath];
301301
}
302302
}
303303
}];
@@ -308,8 +308,8 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
308308
NSIndexPath *currentIndexPath = self.selectedItemIndexPath;
309309

310310
if (currentIndexPath) {
311-
if ([self.delegate respondsToSelector:@selector(collectionView:willEndDraggingItemAtIndexPath:)]) {
312-
[self.delegate collectionView:self.collectionView willEndDraggingItemAtIndexPath:currentIndexPath];
311+
if ([self.delegate respondsToSelector:@selector(collectionView:layout:willEndDraggingItemAtIndexPath:)]) {
312+
[self.delegate collectionView:self.collectionView layout:self willEndDraggingItemAtIndexPath:currentIndexPath];
313313
}
314314

315315
self.selectedItemIndexPath = nil;
@@ -336,8 +336,8 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
336336
strongSelf.currentView = nil;
337337
[strongSelf invalidateLayout];
338338

339-
if ([strongSelf.delegate respondsToSelector:@selector(collectionView:didEndDraggingItemAtIndexPath:)]) {
340-
[strongSelf.delegate collectionView:strongSelf.collectionView didEndDraggingItemAtIndexPath:currentIndexPath];
339+
if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didEndDraggingItemAtIndexPath:)]) {
340+
[strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didEndDraggingItemAtIndexPath:currentIndexPath];
341341
}
342342
}
343343
}];

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ Getting Started
2222
1. Drag the `LXReorderableCollectionViewFlowLayout` folder into your project.
2323
2. Initialize/Setup your collection view to use `LXReorderableCollectionViewFlowLayout`.
2424

25-
3. The collection view controller that is to support reordering capability must conforms to `LXReorderableCollectionViewDelegateFlowLayout` protocol. For example,
25+
3. The collection view controller that is to support reordering capability must conforms to `LXReorderableCollectionViewDatasource` protocol. For example,
2626

27-
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)layout itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath {
27+
- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath {
2828
id object = [mutableArray objectAtIndex:fromIndexPath.item];
2929
[mutableArray removeObjectAtIndex:FromIndexPath.item];
3030
[mutableArray insertObject:object atIndex:ToIndexPath.item];
3131
}
3232

33-
4. Setup your collection view accordingly to your need, run and see it in action! :D
33+
4. You can listen to some dragging events through comforming to `LXReorderableCollectionViewDelegateFlowLayout` methods.
34+
5. Setup your collection view accordingly to your need, run and see it in action! :D
3435

3536
Changes
3637
============
@@ -51,7 +52,7 @@ Requirements
5152
============
5253

5354
- ARC
54-
- iOS 6
55+
- iOS 6 and above preferred
5556
- Xcode 4.5 and above
5657

5758
Credits

0 commit comments

Comments
 (0)