Iphone 库中图像的元数据
我需要从图书馆获取图像的元数据。我正在使用代码Iphone 库中图像的元数据,iphone,metadata,uiimagepickercontroller,Iphone,Metadata,Uiimagepickercontroller,我需要从图书馆获取图像的元数据。我正在使用代码 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL]; ALAssetsLibrary *library =
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *representation = [asset defaultRepresentation];
metadataDict = [representation metadata];
NSLog(@"%@",metadataDict);
} failureBlock:^(NSError *error) {
NSLog(@"%@",[error description]);
}];
[library release];
}
我使用的是IOS 4.2
但是我没有得到元数据。有人能帮我吗?你发布的代码似乎没有任何问题。我已经在模拟器和设备上试过了,效果很好。苹果公司的
元数据
方法文档说明:
如果表示形式是系统无法解释的,则返回nil
因此,这很可能意味着您选择的图像没有任何元数据,或者图像的格式库无法识别
您尚未在方法中定义metadataDict
,因此如果要在块外使用,必须保留它
metadataDict = [[representation metadata] retain];
可能您还必须使用\u块
标识符声明它
__block NSDictionary *metaDataDict;
[representation metadata]唯一的问题是它非常昂贵并且占用大量内存。当我用大量照片库照片进行测试时,它崩溃了。@Puransing-Sing,这个问题的解决方案是什么?由于同样的原因,我面临崩溃