问题
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