mirror of
https://gitee.com/shuto/cordova-imagePicker.git
synced 2026-05-23 00:05:03 +08:00
Updated in iOS to reduce peak memory footprint. Also updated cancel plugin result to an empty array in iOS.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user