Martin
Martin

Reputation: 2873

How to share multiple file via UIDocumentInteractionController?

I am trying to implement share multiple file to Facebook , mail ,google driver and whatsapp.

I can share one file via UIDocumentInteractionController like the following code:

    NSString *filePath = [NSString stringWithFormat:@"%@/%@", directory, [fileList objectAtIndex:selectedIndexPath.row]] ;
    url = [NSURL fileURLWithPath: filePath] ;

    documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
    [documentInteractionController setDelegate:self];
    documentInteractionController.UTI = @"net.whatsapp.image";
    [documentInteractionController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];

How to share multiple file via UIDocumentInteractionController without using UIActivityViewController ?

If use NSMutableArray , and add multiple object of url. How to set NSMutableArray to UIDocumentInteractionController ?

Thanks in advance.

Upvotes: 2

Views: 3919

Answers (1)

Dev
Dev

Reputation: 1213

To share multiple files you can use UIActivityViewController.

UIImage *image = [UIImage imageWithCGImage:self.imgView.image.CGImage];

NSArray* dataToShare = @[image, image2, image3];  // Any data you want to share.

UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
                                  applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];

This might help you.

Upvotes: 3

Related Questions