我的代码如下:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL
resultBlock:^(ALAsset *asset) {
NSDictionary *imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata];
self.photoInfoDic = imageMetadata;
NSLog(@"哈哈哈%@", self.photoInfoDic);
NSDictionary *gpsDic = [imageMetadata objectForKey:@"{GPS}"];
/* gpsDic 里面即是照片的GPS信息,具体可以输出看看*/
self.photo = [info objectForKey:UIImagePickerControllerEditedImage];
[self goFilterViewController];
}
failureBlock:^(NSError *error) {
}];
}
实现的效果就是,有些照片可以获取到gps,有些不可以。比如某张照片,iPhone里面是可以显示地理位置的,就是iPhone自带的相册,我用QQ发布到空间,QQ是也是可以获取到照片的地理位置的。唯独我这个代码,有些照片可以,有些不可以。很奇怪,求解?
最后用第三方的图片选择器就能获取到,自带的这个获取不到,暂时找不到原因