Translate

2013年3月28日 星期四

取得照片拍照时间跟地理位置信息

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
if(picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary){
//UIImage *image= [info objectForKey:UIImagePickerControllerOriginalImage];

NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL]; 
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL
resultBlock:^(ALAsset *asset) {
NSDictionary* imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata]; 
NSDictionary *GPSDict=[imageMetadata objectForKey:(NSString*)kCGImagePropertyGPSDictionary];
NSLog(@"%@",GPSDict);
NSLog(@"%@",imageMetadata);
/* GPSDict 里面即是照片的GPS信息,具体可以输出看看*/
}
failureBlock:^(NSError *error) {
}];
} 
}

沒有留言:

張貼留言