我想让用户截取他在 UIWebView 中选择的特定区域的屏幕截图。为此,我想做的是启用缩放和拖动,但避免所有其他用户交互。
我已经没有关注他们点击的任何链接,但是我没有找到一种方法来控制当他们点击 smth 时的 javascripts 调用,或者如果他们点击 texfield 时控制键盘的显示。
有任何想法吗?谢谢!
我想让用户截取他在 UIWebView 中选择的特定区域的屏幕截图。为此,我想做的是启用缩放和拖动,但避免所有其他用户交互。
我已经没有关注他们点击的任何链接,但是我没有找到一种方法来控制当他们点击 smth 时的 javascripts 调用,或者如果他们点击 texfield 时控制键盘的显示。
有任何想法吗?谢谢!
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);
您可以在 UIWebView 上放置一个透明视图,并且只允许捏缩放和滚动手势落入 UIWebView。这是首先想到的。