PHImageResultIsInCloudKey:
A Boolean value indicating whether the photo asset data is stored on the local device or must be downloaded from iCloud. (NSNumber)
If YES,no image was provided,because the asset data must be downloaded from iCloud. To download the data,submit another request,and specify YES for the networkAccessAllowed option.
但是,即使资源已经完全下载到设备(在我的应用程序中下载,也在照片应用程序中打开),资产即将存储在iCloud照片库中,此键始终为YES.
如果图像不可用,我想给用户一个下载的可能性(但是不要自动执行,至少在没有Wifi时).
那么如何查看图片是否需要下载呢?
更好奇:当我的结果块
requestImageForAsset:的targetSize:contentMode:选项:resultHandler:
被要求需要下载的图像,在得到一个较小和降级的版本后,我得到了requestImage == nil的最后一次调用.
在这种情况下,即使没有图像,即使我没有图像,图像仍然必须从iCloud下载,因为只有当前可用的照片应用程序的一个小缩略图.
我在iPhone和iPad上测试了不同的iOS 8版本(8.1.x,8.2 beta,8.3 beta)的行为总是相同的.
在Photos应用程序中打开图像后,结果处理程序的最后一次调用将具有完整大小的图像,但PHImageResultIsInCloudKey仍将为YES.
以下是我如何请求图像的代码:
PHImageRequestOptions *options = [[PHImageRequestOptions alloc]init]; options.deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic; options.networkAccessAllowed = NO; [self.imageManager requestImageForAsset:asset targetSize:size contentMode:PHImageContentModeAspectFill options:options resultHandler:^(UIImage *requestedImage,NSDictionary *info) { // Checking for requestedImage and the info keys here // When a full sized image was loaded,the result of PHImageResultIsInCloudKey is still YES // When a full sized image couldn't be loaded cause it's in the cloud,isDegraded is NO and PHImageResultIsInCloudKey is YES (as always) and requestedImage is nil }];