A UIImagePickerController-like assets picker that utilizes ARMultiSelectGestureRecognizer for swipe-to-select
Objective-C Shell Ruby C C++
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Classes
Demo
Resources
.gitignore
ARSwipeToSelectPickerController.podspec
LICENSE
README.md

README.md

ARSwipeToSelectPickerController

animatedgif

A UIImagePickerController-like assets picker that utilizes ARMultiSelectGestureRecognizer for swipe-to-select

Adding to your project

The easiest way to add ARSwipeToSelectPickerController to your project is via CocoaPods:

pod 'ARSwipeToSelectPickerController'

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.

Use

  1. Import the header: #import "ARSwipeToSelectPickerController.h"
  2. Conform to the ARSwipeToSelectPickerControllerDelegate protocol, implement its delegate methods
  3. Instantiate the controller:
ARSwipeToSelectPickerController *picker = [[ARSwipeToSelectPickerController alloc] initWithDelegate:self];
[self.navigationController pushViewController:picker animated:YES];

You can also show the picker modally by embedding it inside a UINavigationController first:

ARSwipeToSelectPickerController *picker = [[ARSwipeToSelectPickerController alloc] initWithDelegate:self];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:picker];
[self presentViewController:nav animated:YES completion:nil];

Delegate Methods

#pragma mark - ARSwipeToSelectPickerControllerDelegate methods

- (void) swipeToSelectPickerControllerDidCancel:(ARSwipeToSelectPickerController *)sender
{
    // use popViewControllerAnimated if using navigation controller for viewcontroller stack
    //[self.navigationController popViewControllerAnimated:YES];

    // use dismissViewControllerAnimated if not using a navigation controller
    //[self dismissViewControllerAnimated:YES completion:nil];
}

- (void) swipeToSelectPickerController:(ARSwipeToSelectPickerController *)sender didFinishPickingMediaWithAssets:(NSArray *)assets
{
    // Use MWPhotoBrowser to show the selected photos
    [self dismissViewControllerAnimated:NO completion:^{
        NSMutableArray *tmpArray = [[NSMutableArray alloc] initWithCapacity:[assets count]];
        [assets enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            UIImage *image = [UIImage imageWithCGImage:[[((ALAsset *) obj) defaultRepresentation] fullScreenImage]];
            [tmpArray addObject:[MWPhoto photoWithImage:image]];
        }];
        self.photos = tmpArray;
        MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
        browser.displayActionButton = NO;
        [browser setInitialPageIndex:0];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self presentViewController:browser animated:YES completion:nil];
        });
    }];
}

Or if you are inside a UINavigationController stack, do something like the following to dismiss the picker controller:

[self.navigationController popToViewController:self animated:YES];

Demo

A cool demo can be found in the demo folder!

Co-Authors

Bitdeli Badge