库中图像的元数据
我需要从库中获取图像的元数据。我正在使用的代码
- (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 但我没有得到元数据。有人可以帮我解决这个问题吗?
I need to get the meta data of the image from the library. I am using the code
- (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];
}
I am using IOS 4.2
But I am not getting the meta data.Can any one help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您发布的代码似乎没有任何问题。我已经在模拟器和设备上尝试过了,它可以工作。 Apple 的
metadata
方法文档指出:因此,这很可能意味着您选择的图像没有任何元数据,或者图像的形式是库无法识别的。
您尚未在方法中定义
metadataDict
,因此如果您想在块之外使用,则必须保留它。可能您还必须使用
__block
标识符来声明它。There doesn't seem to be anything wrong with the code you posted. I have tried it in the simulator and on a device and it works. Apple's documentation for the
metadata
method states:So this most likely means that the image you have chosen either doesn't have any metadata or the the image is in a form that the library doesn't recognize.
You have not defined
metadataDict
in your method so if you want to use outside of your block you have to retain it.Possibly you have have to declare it with the
__block
identifier as well.