本文介绍了如何使用Photos API在iOS 8.0中检索照片扩展(jpg / png)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在iOS 8中使用新的Photos API获取照片的文件扩展名,但直到现在还没有找到方法。在iOS 8.0之前,我会使用ALAssetRepresentation来获取文件扩展名,如:
Am trying to get file extension of photos using the new Photos API in iOS 8 but haven't found a way to do so until now. Before iOS 8.0 I would use ALAssetRepresentation to get the file extension like:
// Get asset representation from asset
ALAssetRepresentation *assetRepresentation = [asset defaultRepresentation];
// Extract file extension from the original file name
NSString* fileExt = [[assetRepresentation filename] pathExtension];
现在有办法获得照片的文件扩展名吗?
PS:我正在使用新的Photos API,因为我需要访问我的照片应用中的所有照片,而ALassetsLibrary只能访问最近添加的照片。
Is there any way to get file extension of photos now? PS: I am using new Photos API as I need to access all photos in my photos app, and ALassetsLibrary gives access to "Recently Added" photos only.
推荐答案
我知道了。
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:imageRequestOptions resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
NSLog(@"info - %@", info);
}];
PHImageFileDataKey = <PLXPCShMemData: 0x179ab6d0> bufferLength=1384448 dataLength=1384448;
PHImageFileOrientationKey = 1;
PHImageFileSandboxExtensionTokenKey = "c05e608acaf0bb212086ed2d512ccc97ea720ac3;00000000;00000000;0000001a;com.apple.app-sandbox.read;00000001;01000003;0000000000030b8c;/private/var/mobile/Media/DCIM/102APPLE/IMG_2607.JPG";
PHImageFileURLKey = "file:///var/mobile/Media/DCIM/102APPLE/IMG_2607.JPG";
PHImageFileUTIKey = "public.jpeg";
PHImageResultDeliveredImageFormatKey = 9999;
PHImageResultIsDegradedKey = 0;
PHImageResultIsInCloudKey = 0;
PHImageResultIsPlaceholderKey = 0;
PHImageResultWantedImageFormatKey = 9999;
这篇关于如何使用Photos API在iOS 8.0中检索照片扩展(jpg / png)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!