Updated in iOS to reduce peak memory footprint. Also updated cancel plugin result to an empty array in iOS.

This commit is contained in:
CSullivan102
2014-04-29 20:50:18 -04:00
parent 13eea796fc
commit 85f1e7a75b
2 changed files with 52 additions and 62 deletions
@@ -20,7 +20,7 @@
- (id)initImagePicker
{
ELCAlbumPickerController *albumPicker = [[ELCAlbumPickerController alloc] initWithStyle:UITableViewStylePlain];
self = [super initWithRootViewController:albumPicker];
if (self) {
self.maximumImagesCount = 4;
@@ -63,43 +63,19 @@
- (void)selectedAssets:(NSArray *)assets
{
NSMutableArray *returnArray = [[NSMutableArray alloc] init];
for(ALAsset *asset in assets) {
id obj = [asset valueForProperty:ALAssetPropertyType];
if (!obj) {
continue;
}
NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
CLLocation* wgs84Location = [asset valueForProperty:ALAssetPropertyLocation];
if (wgs84Location) {
[workingDictionary setObject:wgs84Location forKey:ALAssetPropertyLocation];
}
[workingDictionary setObject:obj forKey:UIImagePickerControllerMediaType];
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
//so use UIImageOrientationUp when creating our image below.
ALAssetRepresentation *assetRep = [asset defaultRepresentation];
CGImageRef imgRef = nil;
UIImageOrientation orientation = UIImageOrientationUp;
if (_returnsOriginalImage) {
imgRef = [assetRep fullResolutionImage];
orientation = [assetRep orientation];
} else {
imgRef = [assetRep fullScreenImage];
}
UIImage *img = [UIImage imageWithCGImage:imgRef
scale:1.0f
orientation:orientation];
[workingDictionary setObject:img forKey:UIImagePickerControllerOriginalImage];
[workingDictionary setObject:asset forKey:@"ALAsset"];
[workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:UIImagePickerControllerReferenceURL];
[returnArray addObject:workingDictionary];
}
}
if (_imagePickerDelegate != nil && [_imagePickerDelegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
[_imagePickerDelegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:returnArray];
} else {