无法快速共享PDF(仅WhatsApp)

时间:2019-12-12 10:57:32

标签: swift pdf document whatsapp uiactivityviewcontroller

我想从应用程序共享pdf文件。我收到一些“无法共享”文档PDF的错误消息。我在someFiles中没有收到错误。这是我的代码:

my_new_method!

1 个答案:

答案 0 :(得分:0)

  

检查我的简单代码可能对您有所帮助,不要忘记为whatsapp配置共享设置,只有它会出现在共享实例中。

@objc func shareTapped() {

        do {
            let data = try Data(contentsOf: URL(fileURLWithPath: documentPath!))
            let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [docTitle!,data], applicationActivities: nil)
            activityViewController.popoverPresentationController?.sourceView = self.view

            self.present(activityViewController, animated: true, completion: nil)
            print("pdf file loading...")
        }
        catch {
            let msgView = Utils.swiftMeassageView(title: "", message: "PDF file not found.", theme: .info)
            SwiftMessages.show(view: msgView)
        }
    }