What you've got in each element of your array is an asset URL. To get from an asset URL to an image, start with the ALAssetsLibrary object, call assetForURL:resultBlock:failureBlock:
to fetch the corresponding asset (the photo file), and, in the resultBlock
, pull out the thumbnail and use it in your interface.
Here's some typical code for getting from an ALAsset to a usable image:
ALAsset* photo = // let's assume you've obtain an asset
CGImageRef im = photo.aspectRatioThumbnail;
UIImage* im = [UIImage imageWithCGImage:im scale:0
orientation:UIImageOrientationUp];
However, you've made a very odd design choice here. assetForURL:resultBlock:failureBlock:
is time-consuming and operates asynchronously; it is not suitable for calling in a table view data source method (when you configure your cells), which needs to be fast. In didFinishPickingMediaWithInfo:
, why did you ask the info
for its UIImagePickerControllerReferenceURL
? You don't need an array of URLs; you need an array of images! The info
was offering you the image right then (its UIImagePickerControllerOriginalImage
); why didn't you take it when it was offered? You could have just grabbed the image, sized it down, and stuck the sized-down image into your table data model, ready for use.
(Also, it is silly and wasteful to call reloadData
every time through the for
loop. You should call it just once, after you've gathered all the images into your model.)