I have created a webview in a viewController and loading a page like this
func loadAddress(){
let requestURL = NSURL(string:"http://www.example.com/")
let request = NSURLRequest(url: requestURL as! URL)
webview.loadRequest(request as URLRequest)
}
And calling this in
viewDidLoad
I have somelinks in the page with URL parameters like this
http://www.example.com?id=1&title=ABC
Now when a user clicks this link from the app then instead of redirecting to URL, I want to get the parameters from URL and open a dialog box in iOS
I have found some examples in Objective C but I am looking for a solution in Swift 3
PS: I have access to this website's HTML I can replace links as required by Xcode
EDIT: Here is what i have tried, in the same file where my webview is i wrote this function
func webView(_ webView: UIWebView,shouldStartLoadWith request: URLRequest,navigationType: UIWebViewNavigationType) -> Bool {
let scheme = request.url!
NSLog(scheme.absoluteString)
return false
}
and also made sure that the class is a delegate to webview
what am i doing wrong?