I can get HTML pages, YouTube videos, etc. to load into this WKWebView and display correctly, but PDFs tint the entire view, are cropped at the bottom, and cover the background of the nav bar when scrolled up. I want the PDF to only display in the safe area below the nav bar.
Here's my code:
// add web view
let webConfiguration = WKWebViewConfiguration()
let customFrame = CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: 0, height: self.view.frame.size.height))
let webView = WKWebView (frame: customFrame, configuration: webConfiguration)
webView.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(webView)
webView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true
webView.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
webView.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
webView.heightAnchor.constraint(equalTo: self.view.heightAnchor).isActive = true
webView.uiDelegate = self
// embed pdf in web view
let pdfUrl = URL(string: self.pdfUrlString)
let pdfRequest = URLRequest(url: pdfUrl!)
webView.load(pdfRequest)
I've tried adding
webView.autoresizesSubviews = true
webView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
from this Stack Overflow answer and it doesn't help.
Here are screenshots of the issues I'm seeing:
Please help! Thank you!