ios - Detecting when a user clicks on a webform loaded in a UIWebView or WKWebView -



ios - Detecting when a user clicks on a webform loaded in a UIWebView or WKWebView -

i'd observe when user presses webform button nowadays in html page loaded in ios webview (ideally using wkwebview). is possible? , if so, how?

general comment:

i know wkwebview has limitations hence if know method works wkwebview please share it. if know method works uiwebview please share can utilize start find solution wkwebview based app.

to using wkwebview, need conform wknavigationdelegate, , set webview's navigationdelegate.

the method you're looking - webview:decidepolicyfornavigationaction:decisionhandler:, can determine whether allow link touch or not. can target url navigationaction.request.url.

a quick example:

- (void)webview:(wkwebview *)webview decidepolicyfornavigationaction:(wknavigationaction *)navigationaction decisionhandler:(void (^)(wknavigationactionpolicy))decisionhandler { if ([navigationaction.request.url.relativestring hasprefix:klocalcontentprefix]) { // show local content // don't allow webview load url. decisionhandler(wknavigationactionpolicycancel); } // allow webview load url. decisionhandler(wknavigationactionpolicyallow); }

to in uiwebview, it's same, except conform -(bool)webview:shouldstartloadwithrequest:navigationtype: in uiwebviewdelegate. recommend using webkit if possible!

ios webforms uiwebview wkwebview

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -