如何打开Acrobat Reader阅读pdf文件?

How to open Acrobat Reader to read pdf file?

我有很多 .pdf 格式的文件。我在集合视图中显示文件的名称。现在在 didSelectItemAtIndex 方法中,我想打开 Acrobat Reader 来打开 pdf 文件。我该如何实施? Acrobat Reader 是否也有一个 URL 方案,以便我可以检测该应用程序是否在 phone 上?

首先获取您的 pdf 文件的路径。他们称之为通过 acrobat 打开 pdf reader

UIApplication.shared.open(URL(string: "com.adobe.adobe-reader://PDFFilePath")!)

不过在这之前确认一下reader是否已经安装了也无妨

if UIApplication.shared.canOpenURL(theURL! as URL) {

}

这是 Adob​​e reader 的应用架构:

com.adobe.Adobe-Reader

在 Swift 中,您可以执行以下操作:

           var docController: UIDocumentInteractionController?
    if let path = Bundle.main.path(forResource: "PDF-NAME", ofType: "pdf") {
            let targetURL = NSURL.fileURL(withPath: path)
            docController = UIDocumentInteractionController(url: targetURL)
            let url = NSURL(string:"com.adobe.Adobe-Reader:");
            if UIApplication.shared.canOpenURL(url! as URL) {
                docController!.presentOpenInMenu(from: .zero, in: self.view, animated: true)
                print("Adobe-Reader")
            }else{
                print("Adobe-Reader is not installed")
            }
    }

并在 plist 中添加以下应用架构。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>com.adobe.Adobe-Reader</string>
</array>