gpt4 book ai didi

iphone - 库中图像的元数据

转载 作者:行者123 更新时间:2023-12-03 19:00:40 24 4
gpt4 key购买 nike

我需要从库中获取图像的元数据。我正在使用代码

- (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但我没有获取元数据。有人可以帮我解决这个问题吗?

最佳答案

您发布的代码似乎没有任何问题。我已经在模拟器和设备上尝试过了,它可以工作。 Apple 的 metadata 方法文档指出:

Returns nil if the representation is one that the system cannot interpret.

因此,这很可能意味着您选择的图像没有任何元数据,或者图像的形式是库无法识别的。

您尚未在方法中定义 metadataDict,因此如果您想在 block 之外使用,则必须保留它。

metadataDict = [[representation metadata] retain];

可能您还必须使用 __block 标识符来声明它。

__block NSDictionary *metaDataDict;

关于iphone - 库中图像的元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4344379/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com