是否可以直接在iBooks而不是浏览器中打开PDF文件(深层链接?)

时间:2018-04-18 17:16:40

标签: ios deep-linking ibooks

Hello I World希望直接​​在iBooks中打开PDF,而不是让它们在Safari中打开。

例如,这将是我的网站:http://www.ti.com/lit/ds/symlink/sn74ls00.pdf

当我访问此链接时,它将在我的浏览器中打开。但我想让它在iBooks中自动打开。这可能与某些类似的深层链接有关吗?

1 个答案:

答案 0 :(得分:0)

如果您想使用iBooks打开文档,可以这样做:

let docController: UIDocumentInteractionController =  UIDocumentInteractionController(url: localURL)
if UIApplication.shared.canOpenURL(URL(string: "itms-books:")!) {
        docController.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
}

UIDocumentInteractionController仅支持本地文件,因此您必须将PDF文件下载到用户设备,然后才能在iBooks中打开它。这是打开PDF文件的非常糟糕的方法,因为您要将每个文件保存到设备。您应该使用WebView并在其中打开PDF。这很简单:

let request = URLRequest(url: URL(string: "http://www.ti.com/lit/ds/symlink/sn74ls00.pdf")!)
self.webView.loadRequest(request)
相关问题