CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Apr 2016 |
Maintained by Wes Smith.
This is an iOS, Objective-C alternative to UIImagePickerController
that looks almost exactly the same, but provides the ability to select multiple images. It's as easy to setup as UIImagePickerController
and it works in both portrait and landscape orientations. It requires the addition of AssetsLibrary.framework. This code uses ARC.
Note: Using AssetsLibrary.framework will prompt users to grant access to their photos.
The easiest way to add WSAssetPickerController
to your project is via CocoaPods:
pod 'WSAssetPickerController'
Alternatively you could copy all the files in the src
directory into your project. Be sure 'Copy items to destination group's folder' is checked.
#import "WSAssetPicker.h"
WSAssetPickerController
passing an instance of ALAssetsLibrary
WSAssetPickerControllerDelegate
protocol and set the picker's delegateWSAssetPickerController
instancepng
files: WSAssetViewSelectionIndicator.png
and [email protected]
or make your own.Check out the demo project for more details.
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
self.assetsLibrary = library;
WSAssetPickerController *controller = [[WSAssetPickerController alloc] initWithAssetsLibrary:library];
[self presentViewController:controller animated:YES completion:NULL];
- (void)assetPickerControllerDidCancel:(WSAssetPickerController *)sender
{
// Dismiss the WSAssetPickerController.
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)assetPickerController:(WSAssetPickerController *)sender didFinishPickingMediaWithAssets:(NSArray *)assets
{
// Dismiss the WSAssetPickerController.
[self dismissViewControllerAnimated:YES completion:^{
// Do something with the assets here.
}];
}
Note: The ALAsset
objects in the assets
array are only valid for the lifetime of the ALAssetsLibrary
instance they came from.