在这里,我尝试在 Safari浏览器中打开扩展名为 .pdf 的hosts.tmp
。但是代码不起作用,我在URL
中得到了零。但是,当我像“ www.google.com” 那样尝试URL
时,效果很好
代码
URL
预先感谢
答案 0 :(得分:-1)
尝试这个。
let cerificateURl = "https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf"
if let myURL = URL(string: url) {
if let data = try? Data(contentsOf: myURL) {
webView.load(data, mimeType: "application/pdf", characterEncodingName: "", baseURL: myURL
}
}
答案 1 :(得分:-1)
尝试这个:
guard let url = URL(string: "your web pdf file link here or you can set from local directory path")
else { return }
UIApplication.shared.open(url)