How to intercept a long click on links in UIWebView?

I want to provide my own action sheet or popover, I don’t want the default system to be one.

Note that:

  • I ask for a long press do not click .
  • I need to know the URL of a link that has been clicked for a long time.
+7
source share
1 answer

To provide your own action sheet or popover, you first need to disable the default context menu. You can do this using javascript using the following code, inside webViewDidFinishLoad

 [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"]; 

Once you disable the default behavior, you can create your own action sheet / popover.

One possible approach is described in the following link:

Configure UIWebView context menu

+11
source

All Articles