0

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

2
  • UIWebView and WKWebView are 2 different things and are not interchangeable. UIWebView is 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 Commented Apr 10, 2023 at 16:10
  • 1
    Does this answer your question? Detect button click (by class name) in WKWebView with JavaScript.evaluate Commented Apr 10, 2023 at 16:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.