我的应用程序使用didFinishPickingMediaWithInfo 拍摄照片,我想将其保存在相机胶卷
UIImage *orgImage=[[UIImage alloc]init];
orgImage = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
{
UIImageWriteToSavedPhotosAlbum(orgImage, nil, nil, nil);}
我保存完成,但是当我从相机胶卷获取相同的图像时 元数据没有dateTimeOriginal
/ Camera Roll
if ([info valueForKey:UIImagePickerControllerReferenceURL] != nil)
{
NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];
if(imageURL)
{
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:imageURL
resultBlock:^(ALAsset *myasset)
{
ALAssetRepresentation *representation = [myasset defaultRepresentation];
NSDictionary *metadata = representation.metadata;
NSDictionary *exifData = [metadata objectForKey:@"{Exif}"];
NSString *dateTimeOriginal = [exifData objectForKey:@"DateTimeOriginal"];
}
failureBlock:^(NSError *myerror)
{
// Error
}];
}
}
答案 0 :(得分:0)
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *url = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:url
resultBlock:^(ALAsset *asset) {
NSDate *myDate = [asset valueForProperty:ALAssetPropertyDate];
NSLog(@"Date: %@", myDate);
} failureBlock:^(NSError *error) {
NSLog(@"Error");
}];
[picker dismissViewControllerAnimated:YES completion:nil];
}