Summary
As of current, my WKWebView is having some minor scrolling issues. It is hiding the very bottom of the web page. This happens until the user scrolls all the way down the embedded scroll view within the web page.
When the WebView is scrolled at the top of the page, it shows the top bar of the web page; whereas when it is scrolled to the bottom of the page, it shows the bottom bar of the web page. Safari for iOS seems to fit the web page content perfectly, however.
My WKWebView vs. Safari's WKWebView Comparison
- My App – Top of Page Scrolled: Screenshot 1
- My App – Bottom of Page Scrolled: Screenshot 2
- Safari's Layout – Desired Outcome: Screenshot 3
As you can see, Safari's WKWebView allows for both of the top and bottom bars to be visible at all times. How do I go about doing this with my application?
ViewController.swift
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate, UIScrollViewDelegate {
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.navigationDelegate = self
self.view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let webPlayer = URL(string: "http://web.alizarin.ca")
let webRequest = URLRequest(url: webPlayer!)
webView.load(webRequest)
webView.allowsBackForwardNavigationGestures = true
webView.scrollView.delegate = self
webView.scrollView.bounces = false
webView.scrollView.contentSize = webView.bounds.size
}
// Disable Zoom for WebView
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
return nil
}
}
Side note: I have tried commenting out every UIScrollView line of code, and still nothing.