Is it possible to share an image via UIActivityViewController and retain exif data?

血红的双手。 提交于 2019-12-23 10:57:04

问题


I have an app which saves images to a custom album within the camera roll via

    [library writeImageToSavedPhotosAlbum:[newTestImage CGImage] metadata:metadata
      completionBlock:^(NSURL *assetURL, NSError *error) {
        //error
      }
    ];

This works fine, however, I would then like to allow the user to share these images from within the app, I was doing it via

    ALAsset *assetToShare = self.images[indexPath.row];
        NSString *stringToShare = @"…..";
        NSArray *dataToShare = @[assetToShare, stringToShare];

        UIActivityViewController *activityVC = [[UIActivityViewController alloc]
              initWithActivityItems:dataToShare applicationActivities:nil];

        [self presentViewController:activityVC animated:YES completion: ^{
            //Some Expression  
        }];}

However in doing so the image is stripped of all exif data, is there a way I can implement the same functionality but retain the metadata? Thanks very much for any assistance.

Edit: Code used to enter ALAssets

    if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:@"my pics"]) {
                           [self.assetGroups addObject:group];
                           _displayArray = [self.assetGroups objectAtIndex:0]; ...}];

Then:

   [_displayArray enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
    if (result) {
        [self.images addObject:result]; }];

回答1:


Have you tried something like this? Just passing the actual image.

ALAsset *assetToShare = self.images[indexPath.row];

ALAssetRepresentation *rep = [assetToShare defaultRepresentation];

UIImage *imageToShare = [UIImage imageWithCGImage:[rep fullResolutionImage]];

NSString *stringToShare = @"…..";
NSArray *dataToShare = @[imageToShare, stringToShare];

UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:dataToShare applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion: ^{
//Some Expression
}];}


来源:https://stackoverflow.com/questions/13439549/is-it-possible-to-share-an-image-via-uiactivityviewcontroller-and-retain-exif-da

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!