I'm having some issues with rendering a multi paged pdf in the WkWebView.
If it's a single page it looks fine. But the first page of any multiple page PDF looks bad. I can't figure out why.
I load the request like this
wkWebView.load(URLRequest(url: request as! URL))
I keep a wkWebView inside a another view and to avoid a scroll in scroll (there is a reason for this I know how scrollView works) I then set the height of the wWebView and it's scrollView to the same height as the contentSize.
wkWebView.frame.size.height = wkWebView.scrollView.contentSize.height wkWebView.frame.size.width = UIScreen.main.bounds.width wkWebView.autoresizingMask = [.flexibleWidth, .flexibleHeight] wkWebView.scrollView.delegate = self
3 Answers
Answers 1
The reason why this happens is because you need to add your wkWebView as a subview to the scrollView that will contain it BEFORE you do the actual request. Otherwise the pages might end up pixelated and they will also not behave correctly when zoomed in.
Solution:
self.scrollView.addSubview(wkWebView) wkWebView.load(URLRequest(url: request as! URL))
Wont work:
wkWebView.load(URLRequest(url: request as! URL)) self.scrollView.addSubview(wkWebView)
Similar to this issue: https://stackoverflow.com/a/44623268/3418097
Answers 2
i am mehedi. i have a apps but don't know how can i promote it. please help me. here is the apps
Answers 3
Use the following methods:
[self.wkWebView loadFileURL:fileURL allowingReadAccessToURL:baseUrl];
Note: FileURL, is the need to load the HTML file path BaseUrl is HTML file path at the next higher level. This is pit, baseUrl and fileURL can't the same!
0 comments:
Post a Comment