禁用 UIWebView 中的图像选择

发布于 2025-01-02 06:37:40 字数 98 浏览 2 评论 0原文

我有一个 UIWebView,其中加载了图像,当我点击图像时,有时它在图像/图像边框上有灰色突出显示。单击/点击图像时如何禁用此功能?我必须通过 javascript 执行此操作吗?

I have a UIWebView with images loaded in it, when I tap on the image sometimes it has a grayish highlight on the image/image border. How do I disable this when I click/tap on the image? Do I have to do this via javascript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

锦欢 2025-01-09 06:37:40

如果您只想禁用链接

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

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {



        return NO;

    }

    return YES;
}

If you want to disable links only

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

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {



        return NO;

    }

    return YES;
}
少跟Wǒ拽 2025-01-09 06:37:40

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

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

你也可以研究一下这个函数。

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

If the image is a link, the below function may be helpful.

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

You can also look into this function.

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    return NO;
}
何以笙箫默 2025-01-09 06:37:40

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

document.documentElement.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
document.documentElement.style.webkitTouchCallout = "无";

You can try this in your js:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文