2015-10-24 60 views
6
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() 

} 


} 

一切工作正常,但allowBackForwardNavigationGestures = true在xcode 7.1中不起作用。無法在wkwebview中前進和後退。allowedBackForwardNavigationGestures = true在xcode 7.1中不起作用

回答

0

看起來像是干擾導航控制器的interactivePopGestureRecognizer(如果有的話)。

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 
} 

所以我只是在導航堆棧使用WKWebView時禁用此屬性

相關問題