Unable to Override "Link with Highlight" in WKWebView

Hello everyone,

I'm working on an app that uses WKWebView.

My app uses a custom menu and we disable the default menu by overriding with:

WKWebAction.canPerformAction()

However, with the new iOS 18.2 release, I am no longer able to override the "Copy Link with Highlight" option that pops up when highlighting a selection as can be seen from the screenshot:

Has anyone found a work around/bypass for this?

Environment

  • iOS Version: iOS 18.2
  • Device: iPhone 13 Pro
  • App platform: iOS
  • Xcode version: 16.1
  • MacOS: 14.5

I also encountered the same problem,Looking forward to someone helping us。

Subclass WKWebView and add this override:

override func buildMenu(with builder: UIMenuBuilder) {
    super.buildMenu(with: builder)
    builder.remove(menu: .share)
}

Unfortunately this also removes the "Share..." menu item, which I'd rather keep... But if you want to remove everything, that's a possibility.

Unfortunately not available on iOS 18.2

On iOS 18.2, I also encounter this issue. looking forward to a solution

I've been dealing with the same issue, but with help from Apple devs, I was able to find a solution only for iOS 26. You also need to have the latest version of Xcode (26). If I find a solution for iOS 18.x, I will share it here. Here's a snippet showing how to override the "Copy Link with Highlight" feature in iOS 26:

class MyWebView: WKWebView {
    override func buildMenu(with builder: UIMenuBuilder) {
        super.buildMenu(with: builder)
        if #available(iOS 26.0, *) {
            builder.remove(action: UIAction.Identifier("WKActionScrollToTextFragmentGeneration"))
        }
    }
}
Unable to Override "Link with Highlight" in WKWebView
 
 
Q