TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
This is a UIGestureRecognizer subclass to enable Swipe-to-Select/Deselect with a UICollectionView.
The easiest way to add ARSwipeToSelectGestureRecognizer
to your project is via CocoaPods:
pod 'ARSwipeToSelectGestureRecognizer'
Alternatively you could copy all the files in the Classes/
directory into your project. Be sure 'Copy items to destination group's folder' is checked.
#import "ARSwipeToSelectGestureRecognizer.h"
ARSwipeToSelectGestureRecognizer
, pass in a block to handle toggling NSIndexPath
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView.allowsSelection = self.collectionView.allowsMultipleSelection = YES;
// Do any additional setup after loading the view.
ARSwipeToSelectGestureRecognizer *gestureRecognizer = [[ARSwipeToSelectGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:) toggleSelectedHandler:^(NSIndexPath *indexPath) {
if ([[self.collectionView indexPathsForSelectedItems] containsObject:indexPath]) {
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
[self.collectionView cellForItemAtIndexPath:indexPath].alpha = 1.0;
} else {
[self.collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];
[self.collectionView cellForItemAtIndexPath:indexPath].alpha = 0.5;
}
}];
[self.collectionView addGestureRecognizer:gestureRecognizer];
}
ARSwipeToSelectGestureRecognizer
to select multiple photos to share with UIActivityViewController
can be found in the Demo folder.