i made an app with local html file using Xcode and Swift , now i want do something when button is clicked for submitting the form , i have searched a lot but couldn’t find any solutions , please help ..
this is my button
`<button type="button" class="btn btn-success btn-lg" value="Calculate" onclick="ageCalculate()">Calculate</button>`
i want to do something when button Calculate is clicked..
i have tried this method but did not work..
`
func webView(_ webView: WKWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebView.NavigationType) -> Bool {
if (navigationType == .formSubmitted) {
print("Button Clicked in the app")
}
return true
}
`
when i change UIWebView.NavigationType to WKWebview then i got this error..
Reference to member 'formSubmitted' cannot be resolved without a contextual type
and same for if i change it to WKNavigation
UIWebViewandWKWebVieware 2 different things and are not interchangeable.UIWebViewis deprecated and should not be used. And WKWebView doesn't have such event. You should communicate via JS evaluation or messages, check post I link below