【问题标题】:iOS - export multiple pdfiOS - 导出多个 pdf
【发布时间】:2017-03-15 13:05:06
【问题描述】:

在我的应用中,我想实现导出多个 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。 但我不知道如何导出多个文件,谁能帮我...? 谢谢!

【问题讨论】:

    标签: ios objective-c iphone pdf export


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢@abdullahselek,它适用于通过电子邮件和空投共享!但是您是否还可以指定在 UIActivityViewController 显示后如何使用 UIDocumentationInteractionController 将这些 PDF 保存在 iBooks 中?我只看到一个电子邮件选项。谢谢
    • 尝试添加排除类型,如// try adding excluded types activityViewController.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard]; 和更多信息活动类型link
    • 再次感谢@abdullahselek。添加排除类型并没有真正帮助我。在互联网上研究后,我发现我们无法同时打开多个文档。但我仍然选择你的答案作为最好的解决方案,它真的帮助了我:)
    猜你喜欢
    • 2015-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 2018-10-18
    • 2023-03-20
    • 1970-01-01
    相关资源
    最近更新 更多