ARSwipeToSelectPickerController 0.3

ARSwipeToSelectPickerController 0.3

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total12
Week0
Month0

Installs

Apps2
powered by Segment

GitHub

Stars9
Watchers3
Forks2
Issues0
Contributors3
Pull Requests0

Code

Files6
LOCLines of Code 249



  • By
  • Andrew Ng and Ray Tsaihong

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