iOS 8 照片套件.从 iCloud 照片共享相册中获取最大尺寸的图像

iOS 8 PhotoKit. Get maximum-size image from iCloud Photo Sharing albums(iOS 8 照片套件.从 iCloud 照片共享相册中获取最大尺寸的图像)

本文介绍了iOS 8 照片套件.从 iCloud 照片共享相册中获取最大尺寸的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 iСloud 访问全尺寸图像?每次我尝试获取这张图片时,我都会得到 256x342 的图片大小.我也看不到进展.

How get access to the full-size images from iСloud? Every time I try to get this picture, I get image size 256x342. I not see progress too.

代码:

    PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetIdentifier] options:nil];
    PHImageManager *manager = [PHImageManager defaultManager];
    [result enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {

        PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
        options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
        options.synchronous = YES;
        options.networkAccessAllowed = YES;
        options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
            NSLog(@"%f", progress);
        };

        [manager requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:options resultHandler:^(UIImage *resultImage, NSDictionary *info)
         {
             UIImage *image = resultImage;
             NSLog(@"%@", NSStringFromCGSize(resultImage.size));
         }];
    }];

在我点击照片应用程序中的图片之前,这张图片的质量会很差.但是只要我点击图片,它就会下载到设备上,并且是全尺寸的.

Until I click the picture in Photo app, this picture will be of poor quality. But as soon as I click on the picture, it downloaded on the device and will be full-size quality.

推荐答案

我认为下面应该得到全分辨率的图像数据:

I think the below should get the full resolution image data:

 [manager requestImageDataForAsset:asset 
                           options:options 
                     resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) 
             { 
                  UIImage *image = [UIImage imageWithData:imageData]; 

                  //...

             }];

WWDC 视频中介绍了整个照片框架 (PhotoKit):https://developer.apple.com/videos/wwdc/2014/#511

The entire Photos Framework (PhotoKit) is covered in the WWDC video: https://developer.apple.com/videos/wwdc/2014/#511

希望这会有所帮助.

resultHandler 可以被调用两次.我在 30:00 左右链接到的视频对此进行了解释.可能是您只获得了缩略图,而完整的图像将在第二次调用时出现.

The resultHandler can be called twice. This is explained in the video I linked to at around 30:00. Could be that you are only getting the thumbnail and the full image will come with the second time its called.

这篇关于iOS 8 照片套件.从 iCloud 照片共享相册中获取最大尺寸的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:iOS 8 照片套件.从 iCloud 照片共享相册中获取最大尺寸的图像

基础教程推荐