Git Product home page Git Product logo

cglmediapicker's Introduction

CGLMediaPicker

[![CI Status](http://img.shields.io/travis/Chris Ladd/CGLMediaPicker.svg?style=flat)](https://travis-ci.org/Chris Ladd/CGLMediaPicker) Version License Platform

CGLMediaPicker allows the user to choose a piece of multimedia of an array of types provided by the client, and runs a completion block once the user has either successfully chosen, or cancelled for some reason. Influenced by ClusterPrePermissions, with the goal of being lighter weight, and generally allowing clients to be more hands off.

CGLMediaPicker uses the same very nice "fake alert" strategy to dramatically cut down on users opting out. What's more, the picker takes care of all permissions and UI, and is automatically retained in memory for as long as the user is actively choosing.

I mean, seriously: ALAuthorizationStatus? UIImagePickerControllerDelegate? PHImageRequestOptions? Who's got time for that $@*!?

CGLMediaPicker makes letting users provide photos as simple as creating a picker object, configuring it, and:

picker.completion = ^(UIImage *image, NSDictionary *info, NSError *error){
    // doing something nice with your user's chosen image
};

It takes care of presenting the right photo picker or camera components. It takes care of asking for permissions, informing the user why permissions are lacking, when they're lacking, and sends them to Settings.app to take care of any problems they might need to.

In short, CGLMediaPicker lets you, the client, say: I would like the user to give me a piece of media. And then lets you sit back and wait for that media to arrive.

Doesn't that sound nice?

Usage

__weak __typeof(self) weakSelf = self;
    
// initialize a new picker
CGLMediaPicker *picker = [[CGLMediaPicker alloc] initWithViewController:self];

// give it a series of inputs -- this will automatically be narrowed down by the picker to the inputs actually available on the user's device. e.g. if they don't have a camera
picker.inputs = @[CGLMediaPickerOptionCamera, CGLMediaPickerOptionPhotoLibrary, CGLMediaPickerOptionUserLastPhoto];

// tell the user a little about what you'll use their photos for
picker.permissionMessage = NSLocalizedString(@"We'll use your photos to set the background to this view controller.", nil);

// add a completion. note that you don't have to maintain a reference to the picker -- it's stored internally by the class until the user has finished interacting with it.
picker.completion = ^(UIImage *image, NSDictionary *info, NSError *error){
    if (image) {
        weakSelf.imageView.image = image;
    }
};
    
// lastly, go ahead and pick. This will present your options to the user.
[picker pick];

Installation

CGLMediaPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CGLMediaPicker"

Author

Chris Ladd, [email protected]

License

CGLMediaPicker is available under the MIT license. See the LICENSE file for more info.

cglmediapicker's People

Contributors

chrisladd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.