0

我的应用程序使用 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
             }];
        }

    }
4

1 回答 1

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];

}
于 2014-06-09T09:44:05.230 回答