A photo search/picker for iOS using popular image providers like 500px, Flickr, Instagram, Giphy, Google & Bing Images
A photo search/picker for iOS using popular image providers like 500px, Flickr, Instagram, Giphy, Google & Bing Images, combined with a minimalistic image cropper inspired from UIImagePickerController’s.
pod "DZNPhotoPickerController"
Dependencies:
For complete documentation, visit CocoaPods’ auto-generated doc
#import <DZNPhotoPickerController/DZNPhotoPickerController.h>
Before even creating a new instance of DZNPhotoPickerController, it is recommended that you register to the photo services APIs your will need, on your UIViewController’s class method +initialize, like so:
+ (void)initialize
{
[DZNPhotoPickerController registerService:DZNPhotoPickerControllerService500px
consumerKey:YOUR_500px_KEY
consumerSecret:YOUR_500px_SECRET
subscription:DZNPhotoPickerControllerSubscriptionFree];
[DZNPhotoPickerController registerService:DZNPhotoPickerControllerServiceFlickr
consumerKey:YOUR_Flickr_KEY
consumerSecret:YOUR_Flickr_SECRET
subscription:DZNPhotoPickerControllerSubscriptionFree];
}
Creating a new instance of DZNPhotoPickerController is very similar to what you would do with UIImagePickerController:
DZNPhotoPickerController *picker = [[DZNPhotoPickerController alloc] init];
picker.supportedServices = DZNPhotoPickerControllerService500px | DZNPhotoPickerControllerServiceFlickr;
picker.allowsEditing = YES;
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
You can additionally set more properties:
picker.initialSearchTerm = @"Surf";
picker.cropMode = DZNPhotoEditorViewControllerCropModeCircular;
picker.enablePhotoDownload = YES;
picker.supportedLicenses = DZNPhotoPickerControllerCCLicenseBY_ALL;
picker.allowAutoCompletedSearch = YES;
picker.infiniteScrollingEnabled = YES;
You can opt-in for block methods instead of using the delegate’s methods:
picker.finalizationBlock = ^(DZNPhotoPickerController *picker, NSDictionary *info) {
//Your implementation here
};
picker.failureBlock = ^(DZNPhotoPickerController *picker, NSError *error) {
//Your implementation here
};
picker.cancellationBlock = ^(DZNPhotoPickerController *picker) {
//Your implementation here
};
You can install it as a subspec (if you’re not using DZNPhotoPickerController
)
pod 'DZNPhotoPickerController/Editor'
If you already have an image to edit, simply do:
DZNPhotoEditorViewController *editor = [[DZNPhotoEditorViewController alloc] initWithImage:self.myImage];
editor.cropMode = DZNPhotoEditorViewControllerCropModeCustom;
editor.cropSize = CGSizeMake(CGRectGetWidth(self.view.frame), 200.0);
[editor setAcceptBlock:^(DZNPhotoEditorViewController *editor, NSDictionary *userInfo){
//Your implementation here
}];
[editor setCancelBlock:^(DZNPhotoEditorViewController *editor){
//Your implementation here
}];
// The view controller requieres to be nested in a navigation controller
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:navigation];
[self presentViewController:controller animated:YES completion:nil];
Another great feature of DZNPhotoPickerController is to allow circular edit mode when using UIImagePickerController, just like the Contact app when editing a user’s avatar image. Please note that the circular mode still exports a squared image since it’s sole purpose is for croping alignment. If you need to present a circular image in your app, you will need to implement it yourself.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.cropMode = DZNPhotoEditorViewControllerCropModeCircular;
[self presentViewController:picker animated:YES completion:nil];
There is also block support for UIImagePickerController! It replaces the 2 traditional delegate methods with 2 block properties instead:
picker.finalizationBlock = ^(UIImagePickerController *picker, NSDictionary *info) {
//Your implementation here
};
picker.cancellationBlock = ^(UIImagePickerController *picker) {
//Your implementation here
};
Take a look into the sample project. Everything is there.
The pod dependencies are not being versioned, so before running the project be sure to call:
pod install
Feel free to collaborate with this project!
Big thanks to:
Are you using this control in your apps? Simply add it here.
(The MIT License)
Copyright © 2014 Ignacio Romero Zurbuchen [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.