2

I want to allow the user to take a screenshot of a specific area he choose in a UIWebView. To enable this, what I would like to do is to enable zooming and dragging but avoid every other user interaction.

I´m already not following any link they click, but i didnt found a way to control the javascripts calls when they tap smth, or the display of the keyboard if they tap in a texfield, for example.

Any ideas? Thanks!

2 Answers2

0

You could put a transparent view over the UIWebView and only allow for pinch zoom and scrolling gestures to fall through to the UIWebView. That's the first thing that comes to mind.

Psiticosis
  • 118
  • 8
  • Ok. Im detecting the touches in the overlay view. I try to call TouchesBegan in the UIWebView but it doesnt work. – user2432818 May 29 '13 at 15:13
  • The selected answer in [this thread](http://stackoverflow.com/questions/9209998/forwarding-uigesture-to-views-behind) should be helpful. If it doesn't clear things up, let me know. – Psiticosis May 29 '13 at 15:56
0

The Psiticosis answer is the easier approach to accomplish this, but it's easier to add the "transparent view" into the document body.

Just execute a script on your WebView that add an overlay on the document's body. The script can be like this:

//CSS setup
var styletag = document.createElement("style");
styletag.type = "text/css";
styletag.innerHTML = '#naughty-overlay {position:fixed; height:100%; z-index:9999;}';
styletag.innerHTML += '* {-webkit-user-select:none;}';

//Create the overlay div
var overlay = document.createElement('div');
overlay.id = 'naughty-overlay';

//Append elements
document.body.appendChild(styletag);
document.body.appendChild(overlay);
Community
  • 1
  • 1
cvsguimaraes
  • 12,910
  • 9
  • 49
  • 73