Post

Replies

Boosts

Views

Activity

PDFView highlight button doing nothing & can't override
Hi everyone, I'm trying to make a custom highlight functionality in PDFKit's PDFView on iOS 16. I've tried everything recommended online, and it seems like there's no way to fully override the menu and remove the normal "Highlight" action which actually does nothing if you tap it. I'd be okay with being able to either remove the base Highlight action because I'm able to add my own, or figure out how to handle a tap on that button. Here's what I've tried, and the result: override func buildMenu(with builder: UIMenuBuilder) { super.buildMenu(with: builder) builder.remove(menu: .application) builder.remove(menu: .lookup) builder.remove(menu: .learn) builder.remove(menu: .find) builder.remove(menu: .file) builder.remove(menu: .edit) builder.remove(menu: .services) if #available(iOS 16.0, *) { builder.remove(menu: .document) } let highlightAction = UIAction(title: "Highlight 2", attributes: []) { _ in print("This works") } } let highlightMenu = UIMenu(title: "Highlight 2", options: [.displayInline], children: [highlightAction]) builder.remove(menu: .standardEdit) builder.remove(menu: .share) builder.remove(menu: .toolbar) builder.remove(menu: .text) builder.remove(menu: .font) builder.remove(menu: .format) builder.remove(menu: .transformations) builder.remove(menu: .preferences) builder.remove(menu: .window) builder.remove(menu: .view) builder.replaceChildren(ofMenu: .root, from: { _ in [highlightAction] }) } Please help!
1
0
602
Jan ’24