iOS - 导出多个pdf

iOS - export multiple pdf

在我的应用中,我想实现导出多个 pdf 文件的功能。

目前,我只能使用以下代码导出一个 pdf 文件:

    // get local path url
    NSURL *url = [self getFileURLWithIndexPath:indexPath];
    if(url) {

        BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:[url path]];
        if(!fileExists) {
            NSLog(@"%@", [url path]);
        }

        self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
        [self.docController setDelegate:self];
        BOOL canOpenFile = [self.docController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
        if(!canOpenFile) {
            // No reader PDF
        }
    }

url 是本地 URL 路径。 此方法将弹出,我可以在其中选择要导出的 iBooks。 但我不知道如何导出多个文件,谁能帮我……? 谢谢!

您可以使用 UIActivityViewController 导出多个文件并可以在 UIDocumentationInteractionController 中打开,它提供应用内支持以管理用户与本地系统中文件的交互。

NSArray *dataItems = @[pdf1, pdf2, pdf3];
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataItems
                                  applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{

}];