I am updated an app from ios7 to ios8 and struggling to get UIImagePicker working to load a picture from the "My Photo Stream" category of photos. The UIImagePicker implementation is standard and I retrieve the URL of the selected photo with:
NSURL *url = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
I then use the new IOS8 APIs for loading this photo:
PHFetchResult *result = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
This fails to work. The result.count is zero and no image is found. The URL has an different UUID than if I select the photo from "Moments" or "Camera Roll" but looks well formed. (phone is running 8.1):
url NSURL * @"assets-library://asset/asset.JPG?id=4522DBD1-862C-42BE-AF7C-0D6C76CA7590&ext=JPG"
Anyone have some code to load photos from "My Photo Stream" or a way to disable it for the UIImagePicker display?
Using the older ALAssetsLibrary assetForURL API also fails to load these images.
Loading an image with a specified URL from My Photo Stream using ALAssetsLibrary is discussed here:
ALAssetsLibrary assetForURL: always returning nil for photos in "My Photo Stream" in iOS 8.1
In short, instead of using assetForURL you have to iterate through all items in a Photo Stream and compare their URL with yours. The link above contains a code example.
It looks awkward, works slower than assetForURL, and it is not so easy to determine if there is no any file with specified URL found, but I did not find any other way to do it (except of migrating to Photos framework).