Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

requestImageDataForAsset returns nil image data

Tags:

ios

swift

iphone

I've been stuck with this for couple of days. I've bee trying to get the image within the call back but I always get nil. These the options which I used:

 let options = PHImageRequestOptions()
            options.deliveryMode = .HighQualityFormat
            options.resizeMode = .None

I also tried with options set to nil without any luck. This is the data I got in the info value passed to the block.

[PHImageResultIsInCloudKey: 0, 
 PHImageResultDeliveredImageFormatKey: 9999, 
 PHImageFileURLKey: file:///var/mobile/Media/DCIM/100APPLE/IMG_0052.JPG, 
 PHImageResultRequestIDKey: 84, 
 PHImageResultIsDegradedKey: 0, 
 PHImageResultWantedImageFormatKey: 9999,  
 PHImageResultIsPlaceholderKey: 0, 
 PHImageFileSandboxExtensionTokenKey: 
  64b47b046511a340c57aa1e3e6e07994c1a13853;00000000;00000000;0000001a;com.apple.app-sandbox.read;;00000000;00000000;0000000000000000;/private/var/mobile/Media/DCIM/100APPLE/IMG_0051.JPG]

I also tried using requestImageForAsset and I got the same result. I thought by using requestImageDataForAsset I'll get more control on the data.

Also, I thought the file exists in the cloud, but it is not as PHImageResultIsInCloudKey value is set 0; otherwise, I'd download it.

by the way, I am able to get a smaller version of the image with predefined size of 200x200 inside another view; however, when I try to get the larger version of it, I get nil. I know that the image exists on the phone with higher res (I can see it in the Photos app)

Any help will be appreciated.

like image 503
Mickey Mouse Avatar asked Jun 29 '15 15:06

Mickey Mouse


1 Answers

I had a similar issue and tried setting the networkAccessAllowed option on the PHImageRequestOptions object to YES - that seemed to fix it. For me the issue was definitely that the images were in the cloud as images on the camera roll worked fine but those in the cloud did not.

like image 86
JPInHaliHood Avatar answered Nov 06 '22 23:11

JPInHaliHood