0

my Application use didFinishPickingMediaWithInfo for take photo and i want to save it in camera roll

UIImage *orgImage=[[UIImage alloc]init];
    orgImage = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];

    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
    {
        UIImageWriteToSavedPhotosAlbum(orgImage, nil, nil, nil);}

i save complete but when i get info same image from camera roll meta data not have 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
             }];
        }

    }

1 Answers1

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

}
Rinju Jain
  • 1,692
  • 1
  • 14
  • 23