Determine largest PHAsset image size available on iOS device Determine largest PHAsset image size available on iOS device ios ios

Determine largest PHAsset image size available on iOS device


Using the example project posted in the question I was able to reproduce the issue in the simulator, but when I made the following change I would receive only the largest image:

let targetSize = PHImageManagerMaximumSize


Actually I don't know the reason why Apple would return the degraded 45*60 image with PHImageResultIsDegradedKey=1. For me, I just request the 256*256 image with deliveryMode PHImageRequestOptionsDeliveryModeHighQualityFormat at first, then I use the other PHImageRequestOptions to request full size image like below:

PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];options.networkAccessAllowed = YES;options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info){// code to update the iCloud download progress});[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {// code to update UIImageView or something else.});

And I think, Instagram may be use this similar solution to handle the image from iCloud.


[imageManager requestImageForAsset:asset              targetSize: PHImageManagerMaximumSize              contentMode:PHImageContentModeAspectFill              options:nilresultHandler:^(UIImage *result, NSDictionary *info){    result;}];