how to intercept Button click inside UIWebview on IOS?

后端 未结 3 2028
忘了有多久
忘了有多久 2020-11-30 20:07

I have a HTML form that has certain fields which i am opening inside a UIWebview. On click of a particular button i want to do a in app action.

The approach i\'m usi

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 20:25

    For swift 4.2

    Button code in HTML side:

    Продолжить покупки
    

    UIWebViewDelegate method:

    func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
        if request.url?.scheme == "inapp" {
            if request.url?.host == "home" {
                // do something
            }
        }
        return true
    }
    

提交回复
热议问题