I'm making a hybrid app using WKWebView. There's a problem When you load a page in webview, you can't load it properly if you put # after url.
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void)
I think I need to do this method, but I can't do this and that, and I don't know what to do. Help me
swift ios webview
Creating a project with Single view application and configuring View Controller as shown in the code below, # works fine.
I changed the back of url in urlWithSharp to one, two, three, and so on.
import UIKit
import WebKit
class ViewController: UIViewController,WKNavigationDelegate {
var webView : WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let urlWithSharp = "http://www.owlcarousel.owlgraphic.com/demos/urlhashnav.html#three"
let url = NSURL(string: urlWithSharp)
let request = NSURLRequest(URL: url!)
// // init and load request in webview.
webView = WKWebView(frame: self.view.frame)
webView.navigationDelegate = self
webView.loadRequest(request)
self.view.addSubview(webView)
self.view.sendSubviewToBack(webView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// // Dispose of any resources that can be recreated.
}
}
© 2024 OneMinuteCode. All rights reserved.