Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

allowsBackForwardNavigationGestures = true not working in xcode 7.1

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.

like image 761
khan Avatar asked Oct 24 '15 22:10

khan


1 Answers

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!

like image 120
Vitya Shurapov Avatar answered Oct 18 '22 20:10

Vitya Shurapov