【发布时间】:2011-09-13 23:02:15
【问题描述】:
我已通过使用此功能禁用 UIWebView 的默认调用操作表 -
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
它工作正常,但主要问题是当我长时间点击图像时,UIWebView 的变焦镜头会出现并且我想禁用它,这可能吗?那怎么办?
【问题讨论】:
我已通过使用此功能禁用 UIWebView 的默认调用操作表 -
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
它工作正常,但主要问题是当我长时间点击图像时,UIWebView 的变焦镜头会出现并且我想禁用它,这可能吗?那怎么办?
【问题讨论】:
是的,有几种方法,但其中一些是错误的。 如果您根本不关心用户交互,您可以禁用它。然后他们将只能缩放和移动页面(但不能点击任何链接或任何东西)。
-(void)removeInput{
UIScrollView *webViewContentView;
for (UIView *checkView in [webView subviews] ) {
if ([checkView isKindOfClass:[UIScrollView class]]) {
webViewContentView = (UIScrollView*)checkView;
break;
}
}
for (UIView *checkView in [webViewContentView subviews] ) {
checkView.userInteractionEnabled = NO;
}
}
UIWebView without Copy/Paste and selection rectangle when showing documents
但是,这会导致所有 userInteraction 被禁用,这可能不是您想要的? 仅禁用放大镜我认为是不可能的(尽管我可能错了?)。
好的,如果您不介意禁用文本选择,也可以试试这个。
ObjC
[webView stringByEvaluatingJavaScriptFromString:@"document.onmousedown = function() {return false;}"];
JavaScript
document.onselectstart = function() {return false;} // ie
document.onmousedown = function() {return false;}
来源: http://javascript.internet.com/page-details/disable-text-selection.html
【讨论】: