TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jul 2017 |
Maintained by Nico Prananta.
This is a library to select single photo or multiple photos in iOS 8 or later using iOS Photos framework. I use this library in my app, Delightful app.
Try the sample app in your browser here.
pod 'DLFPhotosPicker'
or copy all the files in Source
folder to your project.DLFPhotosPickerViewController
DLFPhotosPickerViewController *picker = [[DLFPhotosPickerViewController alloc] init];
[picker setPhotosPickerDelegate:self];
[self presentViewController:picker animated:YES completion:nil];
#pragma mark - DLFPhotosPickerViewControllerDelegate
- (void)photosPickerDidCancel:(DLFPhotosPickerViewController *)photosPicker {
[photosPicker dismissViewControllerAnimated:YES completion:nil];
}
- (void)photosPicker:(DLFPhotosPickerViewController *)photosPicker detailViewController:(DLFDetailViewController *)detailViewController didSelectPhotos:(NSArray *)photos {
NSLog(@"selected %d photos", photos.count);
[photosPicker dismissViewControllerAnimated:YES completion:nil];
}
- (void)photosPicker:(DLFPhotosPickerViewController *)photosPicker detailViewController:(DLFDetailViewController *)detailViewController configureCell:(DLFPhotoCell *)cell indexPath:(NSIndexPath *)indexPath asset:(PHAsset *)asset {
// customize the cell based on index path and asset. For example, to mark if the asset has been uploaded.
}
- (void)photosPicker:(DLFPhotosPickerViewController *)photosPicker detailViewController:(DLFDetailViewController *)detailViewController didSelectPhoto:(PHAsset *)photo {
[photosPicker dismissViewControllerAnimated:YES completion:^{
[[PHImageManager defaultManager] requestImageForAsset:photo targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:nil resultHandler:^(UIImage *result, NSDictionary *info) {
NSLog(@"Selected one asset");
}];
}];
}
SampleViewController
class.multipleSelections
. Default: YES. Set this to NO to only select one photo. When this property is set to NO, delegate's photosPicker:detailViewController:didSelectPhoto:
will be called. Implement that method to handle selected asset, then dismiss the photos picker.
Nico Prananta @nicnocquee
If you use this library in your app, let me know :)
MIT.