Ati*_*han 4 ios swift wkwebview ios13
I am using WKWebView to show a pdf file from a remote url. It was working fine in iOS 12 but in iOS 13 it just shows blank screen.
I hit same domain with an image url and that worked fine but it has some issues with pdf files only.
let myURL = URL(string:"somefileurl.pdf") // If I hit this url in safari, It will download a pdf file.
let myRequest = URLRequest(url: myURL!)
webViewPdf.load(myRequest)
Run Code Online (Sandbox Code Playgroud)
我发现响应的内容类型是“ application / octet-stream”,而不是“ application / pdf”
所以我加载WKWebView为:
if let myURL = URL(string:"somefileurl.pdf") {
if let data = try? Data(contentsOf: myURL) {
webViewPdf.load(data, mimeType: "application/pdf", characterEncodingName: "", baseURL: myURL)
}
}
Run Code Online (Sandbox Code Playgroud)