iOS 8 PhotoKit. Get maximum-size image from iCloud Photo Sharing albums(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 照片共享相册中获取最大尺寸的图像
基础教程推荐
- 从 UIWebView 访问元数据 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01
- EditText 中的 setHintTextColor() 2022-01-01
- Firebase 云消息传递令牌未生成 2022-01-01
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01
- 更改 UITableView 部分标题的颜色 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01