是否可以通过UIActivityViewController共享图像并保留exif数据? [英] Is it possible to share an image via UIActivityViewController and retain exif data?

查看:258
本文介绍了是否可以通过UIActivityViewController共享图像并保留exif数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序通过

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

然而,在这样做,图像被删除所有exif数据,有没有办法我可以实现相同的功能,但保留元数据?非常感谢任何帮助。

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.

编辑:用于输入ALAssets的代码

Code used to enter ALAssets

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

然后:

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


推荐答案

只需传递实际图片。

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

这篇关于是否可以通过UIActivityViewController共享图像并保留exif数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆