Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intercept long press on links in UIWebView?

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

Please notice that:

  1. I'm asking about long press not click.
  2. I need to know the URL of the link that is being long pressed.
like image 677
an0 Avatar asked Jul 29 '12 14:07

an0


1 Answers

In order to provide your own action sheet or popover, first you need to disable the default contextual menu. You can do it with javascript by using the following code, inside webViewDidFinishLoad

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

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

One possible approach is described in the following link:

Customize the contextual menu of UIWebView

like image 175
Cezar Avatar answered Sep 23 '22 00:09

Cezar