简体   繁体   English

WKWebView的上下文菜单“下载图像”菜单项未响应…

[英]WKWebView's Context menu “Download Image” menu item not responding…

Image download from right click "Context Menu" not responding in the web page loaded in WKWebview. 从右键单击“上下文菜单”下载的图像在WKWebview中加载的网页中没有响应。 If any body knows help me to identify which delegate method will receive this call or is there any manual implementation needed to get this option work. 如果有谁知道可以帮助我确定哪个委托方法将接收此调用,或者是否需要任何手动实现才能使此选项起作用。


App:Mac Application. Language : Objective C. SDK: Xcode

在这里拍摄

You can intercept context menu items of the WKWebView class by subclassing it and implementing the willOpenMenu method like this: 您可以通过子类化WKWebView类的上下文菜单项并实现willOpenMenu方法,如下所示:

class MyWebView: WKWebView {
    override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {
        for menuItem in menu.items {
            if menuItem.identifier?.rawValue == "WKMenuItemIdentifierDownloadImage" ||
            menuItem.identifier?.rawValue == "WKMenuItemIdentifierDownloadLinkedFile" {
                menuItem.isHidden = true
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM