How to open Acrobat Reader to read pdf file?

前端 未结 2 1450
日久生厌
日久生厌 2020-12-21 21:03

I have many files in .pdf format. I\'m display the names of the files in a collection view. Now in the didSelectItemAtIndex method, I want to open Acrobat Reader to open the

2条回答
  •  独厮守ぢ
    2020-12-21 21:47

    This is the app schema for Adobe reader :

    com.adobe.Adobe-Reader

    In Swift, you can do the following :

               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")
                }
        }
    

    And add below app schemas in plist.

    LSApplicationQueriesSchemes
    
        com.adobe.Adobe-Reader
    
    

提交回复
热议问题