Skip to content

About

A photo picker offering 'use last photo taken', 'take photo', and 'choose from library'

Resources

Stars

71 stars

Watchers

24 watching

Forks

Repository files navigation

CZPhotoPickerController

CZPhotoPickerController simplifies picking, taking, or using the last photo.

It presents a UIActionSheet with the appropriate options for the device, taking into account photo library permissions and whether or not the device has a camera, and then presents a UIImagePickerController (when picking an existing photo or taking a new one) or returns the last photo taken.

It supports the iPhone and iPad.

Installation

pod 'CZPhotoPickerController'

Usage:

__weak typeof(self) weakSelf = self;

self.photoPicker = [[CZPhotoPickerController alloc] initWithCompletionBlock:^(UIImagePickerController *imagePickerController, NSDictionary *imageInfoDict) {

  UIImage *image = imageInfoDict[UIImagePickerControllerEditedImage];
  if (!image) {
    image = imageInfoDict[UIImagePickerControllerOriginalImage];
  }

  weakSelf.imageView.image = image;

  if (weakSelf.presentedViewController) {
    [weakSelf dismissViewControllerAnimated:YES completion:nil];
  }
}];

self.photoPicker.allowsEditing = YES; // optional

self.photoPicker.cropOverlaySize = CGSizeMake(320, 160); // optional

[self.photoPicker presentFromViewController:self];

If allowsEditing is YES, the user will be asked to resize the chosen image. Otherwise, a preview is shown.

If cropOverlaySize is set, the picker will crop the image to the aspect ratio of cropOverlaySize and the preview screen will highlight the cropped area. We'd love a pull request to support pinch and zoom too!

Screenshots

Action sheet

Allows editing

Contributing

Our uncrustify config is in ./config along with a shell script that will uncrustify the files in ./CZPhotoPickerController/. It requires uncrustify 0.60 which is available via homebrew with brew update && brew install uncrustify. Please run ./config/uncrustify.sh to clean up whitespace. Thank you!

Credits

CZPhotoPickerController was created by Brian Cooke and Peyman Oreizy in the development of CareZone Mobile for iOS.

Contact

Brian Cooke @bricooke

Peyman Oreizy @peymano

License

CZPhotoPickerController is available under the Apache 2.0 license. See the LICENSE file for more info.

About

A photo picker offering 'use last photo taken', 'take photo', and 'choose from library'

Resources

Stars

71 stars

Watchers

24 watching

Forks

Releases

Packages

Used by

Contributors

Languages