Excuse me if it's a stupid question but I didn't find an answer: what's the default pdf reader in iPhone? Is it iBooks for all iPhones? I ask about this because in my swift application I want to download a pdf file then open it by the default pdf reader (or another application) of the device. Still now I can do that with to ways: the first is when the button "Download" is tapped, I let the user choose the way of downloading the file via UIDocumentInteractionController
then he can import it using iBooks, Documents, Chrome... I tested it and it works perfectly. The second way is to download the file inside the application (I got the example from the answer of this question) then open it by a pdf reader (the default native one if this is possible).
如果这是一个愚蠢的问题,但我没有找到答案:iPhone的默认pdf阅读器是什么?所有的iphone都是iBooks吗?我之所以问这个问题,是因为在我的swift应用程序中,我想下载一个pdf文件,然后用设备的默认pdf阅读器(或其他应用程序)打开它。现在我仍然可以通过多种方式来实现:首先,当点击“下载”按钮时,我让用户选择通过UIDocumentInteractionController下载文件的方式,然后他可以使用iBooks、Documents、Chrome导入文件……我测试了一下,效果很好。第二种方法是在应用程序中下载文件(我从这个问题的答案中得到了这个例子),然后使用pdf阅读器(如果可能的话,默认的本地文件)打开它。
Any suggestions please?
有什么建议吗?
1 个解决方案
#1
3
If the PDF is available on the web, would it be enough to open it in the browser? This would be a trivially simple method:
如果PDF在web上可用,在浏览器中打开是否足够?这是一种非常简单的方法:
if let url = URL(string: "http://path.to/your.pdf") {
UIApplication.shared.open(url)
}
Safari also offers the option to open the file in another app, if the user wants to use something else.
Safari也提供了在其他应用程序中打开文件的选项,如果用户想要使用其他东西的话。
#1
3
If the PDF is available on the web, would it be enough to open it in the browser? This would be a trivially simple method:
如果PDF在web上可用,在浏览器中打开是否足够?这是一种非常简单的方法:
if let url = URL(string: "http://path.to/your.pdf") {
UIApplication.shared.open(url)
}
Safari also offers the option to open the file in another app, if the user wants to use something else.
Safari也提供了在其他应用程序中打开文件的选项,如果用户想要使用其他东西的话。