首页 > 代码库 > 调用相册照片,获取照片的拍摄时间。

调用相册照片,获取照片的拍摄时间。

已经获取到了 分享下代码 

- (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 = http://www.mamicode.com/[[NSMutableDictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata];

NSDictionary *GPSDict=[imageMetadata objectForKey:(NSString*)kCGImagePropertyGPSDictionary]; 

NSLog(@"%@",GPSDict); 

NSLog(@"%@",imageMetadata); 

/* GPSDict 里面即是照片的GPS信息,具体可以输出看看*/ 

failureBlock:^(NSError *error) { 

}]; 

调用相册照片,获取照片的拍摄时间。