requestImageForAsset resultHandler provides nil resultImage

I'm finding this API is returning nil for the resultImage in iOS 9, even after it was previously called with a non-nil resultImage. Other times it'll never return a higher quality image. So at times my app is showing no image or a blurry image in my collection view cells. How can this be resolved?


imageManager.requestImageForAsset(asset, targetSize: thumbnailSize, contentMode: .AspectFill, options: requestOptions, resultHandler: { (let resultImage: UIImage?, _) -> Void in {
   cell.imageView.image = resultImage
})

Replies

Have you tried printing out the info dictionary in the callback to see if there are errors / other messages?


For example, it might be that you have networkAccessAllowed turned off and the photo is in the cloud.


It could also be that this is a bug - Apple is definitely still ironing out PhotoKit (see https://forums.developer.apple.com/thread/11463,https://forums.developer.apple.com/thread/16244,https://forums.developer.apple.com/thread/13830- all similar issues)requestImageDataForAsset fails with no error'requestImageForAsset' often returns nil for iCloud Photo Library

If this issue is still persisting in the public seed, please file a bug at bugreporter.apple.com with as much detail as possible in recreating the bug, and ideally including a sample project. Thanks!

I am still seeing this with iOS 9.1 beta 4, exactly as described in my bug report I filed August 8th, which includes a very simple sample application that very clearly demonstrates the issue...


rdar://22203781

When the image is nil, there is indeed an error, but it's certainly not very telling: PHImageErrorKey: Error Domain=NSCocoaErrorDomain Code=-1 "(null)"