I am using ELCImagePickerController in my app and I don't want to save the selected fullScreenImage to my array because if i selected 40 iPad images then that is not good.
I want to get data from UIImagePickerControllerReferenceURL
instead of UIImagePickerControllerOriginalImage
from the dict of method - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
.
I have tried:
NSDictionary *dict = [info objectAtIndex:count];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[dict objectForKey:@"UIImagePickerControllerReferenceURL"]]]];//UIImagePNGRepresentation([UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@",[dict objectForKey:@"UIImagePickerControllerReferenceURL"]]] );
NSLog(@"length %d",[data length]);
imageview.image = [UIImage imageWithData:data];
However, every time I am getting 0 bytes. I have tried with all the answers available in forum but no use.
Can anyone answer this please?
in ELCImagePickers "Selected assets" you can do
Then in your other class to save from array
This question ranks well on Google for
UIImagePickerControllerReferenceURL
so I thought I'd add the correct way to useUIImagePickerControllerReferenceURL
in iOS9 and later as ALAssetLibrary has been deprecated in favour of the Photos Framework.The correct way to access the photo using
UIImagePickerControllerReferenceURL
provided in the info dictionary from imagePickerController(_:didFinishPickingMediaWithInfo:) is via Photos Kit PHAsset.A basic implementation of
UIImagePickerControllerDelegate
utilising Photos Framework to fetch the UIImage would look something like this:The code above will not process callbacks when sourceType is
.Camera
since as the info dictionary does not containUIImagePickerControllerReferenceURL
.UIImagePickerControllerReferenceURL
returnsNSURL
object not the string object. Please change your code to -UIImagePickerControllerReferenceURL
returnsNSURL
object forAssets Library
, so you can get image as -Note: ALAssetsLibrary is deprecated in iOS 9.