UIImage *img = imageInfo[@"UIImagePickerControllerOriginalImage"];
NSURL *url = imageInfo[@"UIImagePickerControllerReferenceURL"];
assets-library://asset/asset.jpeg?id=6D3B81E3-7332-46D7-AAB8-023F28AC4ADD&ext=jpeg
NSString *query = url.query;
id=6D3B81E3-7332-46D7-AAB8-023F28AC4ADD&ext=jpeg
NSArray *vars = [query componentsSeparatedByString:@"&"];
NSArray *variable = [var componentsSeparatedByString:@"="];
NSString *name = variable.firstObject;
NSString *value = variable.lastObject;
- (void) imagePickerController:(UIImagePickerController *)thePicker didFinishPickingMediaWithInfo:(NSDictionary *)imageInfo {
[thePicker dismissViewControllerAnimated:YES completion:nil];
for(NSString *key in imageInfo) NSLog(@"-- %@ : %@",key,imageInfo[key]);
UIImage *img = imageInfo[@"UIImagePickerControllerOriginalImage"];
if(img) {
[self traitementImage:img];
return;
}
NSURL *url = imageInfo[@"UIImagePickerControllerReferenceURL"];
if(url) {
NSString *query = url.query;
NSArray *vars = [query componentsSeparatedByString:@"&"];
for(NSString *var in vars) {
NSArray *variable = [var componentsSeparatedByString:@"="];
NSString *name = variable.firstObject;
if([name isEqualToString:@"id"]) {
NSString *value = variable.lastObject;
PHAsset *asset = [PHAsset fetchAssetsWithLocalIdentifiers:@[ value ] options:nil].firstObject;
PHCachingImageManager *cache = [PHCachingImageManager new];
[cache requestImageForAsset:asset
targetSize:CGSizeMake(640, 480)
contentMode:PHImageContentModeAspectFill
options:nil
resultHandler:^(UIImage *image,NSDictionary *infos) {
[self traitementImage:image];
}];
return;
}
}
}
}
Commentaires