如何打开Acrobat Reader来阅读PDF文件?

我有许多.pdf格式的文件。 我在集合视图中显示文件的名称。 现在在didSelectItemAtIndex方法中,我想打开Acrobat Reader来打开PDF文件。 我如何实现这个? Acrobat Reader也有一个URLscheme,以便我可以检测到应用程序是否在电话上?

这是Adobe阅读器的应用程序模式:

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

首先得到您的PDF文件的path。 他们打电话通过acrobat reader打开pdf

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

但是在此之前,确认读者是否已经安装了没有危害

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