如何通过UIDocumentInteractionController共享多个文件?

时间:2014-12-26 10:16:41

标签: ios objective-c facebook

我正在尝试将共享多个文件实施到Facebookmailgoogle driverwhatsapp

我可以通过UIDocumentInteractionController分享一个文件,如下面的代码:

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

如何在不使用UIDocumentInteractionController的情况下通过UIActivityViewController分享多个文件?

如果使用NSMutableArray,则添加url的多个对象。如何将NSMutableArray设置为UIDocumentInteractionController

提前致谢。

1 个答案:

答案 0 :(得分:3)

要共享多个文件,您可以使用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];

这可能会对你有帮助。