Skip to content

Commit 052c2b5

Browse files
committed
Merge branch 'develop'
2 parents a523d1d + 80d9277 commit 052c2b5

File tree

6 files changed

+31
-30
lines changed

6 files changed

+31
-30
lines changed

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.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'LXReorderableCollectionViewFlowLayout'
3-
s.version = '0.1.0.beta1'
3+
s.version = '0.1.0.beta2'
44
s.summary = 'Extends UICollectionViewFlowLayout to support reordering of cells. Similar to long press and pan on books in iBook.'
55
s.homepage = 'https://github.com/lxcid/LXReorderableCollectionViewFlowLayout'
66
s.license = {
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
1010
s.author = 'Stan Chang Khin Boon'
1111
s.source = {
1212
:git => 'https://github.com/lxcid/LXReorderableCollectionViewFlowLayout.git',
13-
:tag => '0.1.0.beta1'
13+
:tag => '0.1.0.beta2'
1414
}
1515
s.platform = :ios, '4.3'
1616
s.source_files = 'LXReorderableCollectionViewFlowLayout/'

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
@end
2020

21-
@protocol LXReorderableCollectionViewDatasource <NSObject>
21+
@protocol LXReorderableCollectionViewDatasource <UICollectionViewDataSource>
2222

2323
- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath;
2424

@@ -29,12 +29,12 @@
2929

3030
@end
3131

32-
@protocol LXReorderableCollectionViewDelegate <NSObject>
32+
@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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ @interface LXReorderableCollectionViewFlowLayout ()
5555
@property (strong, nonatomic) NSTimer *scrollingTimer;
5656

5757
@property (assign, nonatomic, readonly) id<LXReorderableCollectionViewDatasource> dataSource;
58-
@property (assign, nonatomic, readonly) id<LXReorderableCollectionViewDelegate> delegate;
58+
@property (assign, nonatomic, readonly) id<LXReorderableCollectionViewDelegateFlowLayout> delegate;
5959

6060
@end
6161

@@ -121,8 +121,8 @@ - (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttribut
121121
return (id<LXReorderableCollectionViewDatasource>)self.collectionView.dataSource;
122122
}
123123

124-
- (id<LXReorderableCollectionViewDelegate>)delegate {
125-
return (id<LXReorderableCollectionViewDelegate>)self.collectionView.delegate;
124+
- (id<LXReorderableCollectionViewDelegateFlowLayout>)delegate {
125+
return (id<LXReorderableCollectionViewDelegateFlowLayout>)self.collectionView.delegate;
126126
}
127127

128128
- (void)invalidateLayoutIfNecessary {
@@ -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)