import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
var webView : WKWebView!
override func loadView() {
webView = WKWebView()
webView.navigationDelegate = self
self.view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://boooo.com")
webView.loadRequest(NSURLRequest(URL: url!))
webView.allowsBackForwardNavigationGestures = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Everything works fine but allowsBackForwardNavigationGestures = true not working in xcode 7.1. can't go back and forward in wkwebview.
Look like it's interfering with navigationController's interactivePopGestureRecognizer (if you have one).
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
So I just disabled this property at the time of using WKWebView in navigation stack!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With