禁用UIWebView中的图像选择

时间:2012-02-02 05:29:22

标签: javascript iphone objective-c ipad uiwebview

我有一个UIWebView,其中加载了图像,当我点击图像时,有时它在图像/图像边框上有一个灰色的高光。单击/点击图像时如何禁用此功能?我是否必须通过javascript进行此操作?

3 个答案:

答案 0 :(得分:2)

如果您只想禁用链接

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {



        return NO;

    }

    return YES;
}

答案 1 :(得分:1)

如果图像是链接,则以下功能可能会有所帮助。

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request   navigationType:(UIWebViewNavigationType)navigationType 
{
    return NO;
}

您也可以查看此功能。

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    return NO;
}

答案 2 :(得分:0)

你可以在你的js中试试这个:

document.documentElement.style.webkitTapHighlightColor =“rgba(0,0,0,0)”;    document.documentElement.style.webkitTouchCallout =“none”;