2011-06-13 40 views
0

我有一个UIWebView禁用默认调用了动作片使用此 -如何从UIWebView禁用缩放玻璃/镜头?

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

它的正常工作,但主要的问题是,当我很长一段时间的图像上挖掘UIWebView变焦镜头来到那里,我想禁用它,这可能吗?那么如何?

回答

0

是的几种方法,但其中一些是越野车。 如果您根本不关心用户交互,您可以将其禁用。然后他们将只能放大和移动页面(但不能点击任何链接或任何东西)。

-(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

然而这会导致所有用户交互被禁用这可能不是你想要什么? 只是禁用放大镜,我不认为是可能的(虽然我可能是错的?)。


好吧,如果你不介意禁用文本选择,以及你可以试试这个。

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

+0

感谢您的帮助,但我不希望使用户交互禁用,我就只想隐藏变焦当用户点击网页浏览时镜头。 – saadnib 2011-06-14 04:13:53

+0

@saadnib用另一个可能的答案更新了答案。 – 2011-06-14 14:51:52