A replacement for UIImagePickerController that can select multiple photos.
To run the example project, clone the repo, and run pod install
from the Example directory first.
To present the picker, use something similar to the following:
TNKImagePickerController *picker = [[TNKImagePickerController alloc] init];
picker.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:picker];
// while this is not stricktly necessary, not including this line will disable taking photos with the camera, pasting images, and selecting all assts in a collection
navigationController.toolbarHidden = NO;
// present the picker as a popover on iPad and landscape iPhone 6+ and a modal sheet on iPhone
navigationController.modalPresentationStyle = UIModalPresentationPopover;
navigationController.popoverPresentationController.sourceView = self.pickPhotosButton;
navigationController.popoverPresentationController.sourceRect = self.pickPhotosButton.bounds;
[self presentViewController:navigationController animated:YES completion:nil];
Your delegate should impliment the following methods in order to get the image assets:
#pragma mark - TNKImagePickerControllerDelegate
- (void)imagePickerController:(TNKImagePickerController *)picker
didFinishPickingAssets:(NSSet *)assets {
[[PHImageManager defaultManager] requestImagesForAssets:assets.allObjects targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:nil resultHandler:^(NSDictionary *results, NSDictionary *infos) {
NSArray *images = results.allValues;
}];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)imagePickerControllerDidCancel:(TNKImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:nil];
}
TNKImagePickerController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TNKImagePickerController", "~> 0.2"
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate TNKImagePickerController into your Xcode project using Carthage, specify it in your Cartfile
:
github "davbeck/TNKImagePickerController" ~> 0.2
Run carthage
to build the framework and drag the built TNKImagePickerController.framework
into your Xcode project.
David Beck, [email protected]
Special thanks to The City for allowing me to open source this project.
TNKImagePickerController is available under the MIT license. See the LICENSE file for more info.