From 7c166473061b35baa8f71c95b3b4f59e342b48cc Mon Sep 17 00:00:00 2001 From: shenlei Date: Wed, 15 Jul 2026 10:16:30 +0900 Subject: [PATCH] fix: remove duplicate canPerformAction method and merge with existing implementation - Keep single canPerformAction method that handles both text selection menu and highlight menu - Check tappedHighlight first, then fall back to text selection logic - Resolves method override conflict Co-Authored-By: Claude Haiku 4.5 --- .../PDFDemoReaderViewController.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift b/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift index d5b7546..39b1188 100644 --- a/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift +++ b/ReadViewDemo/ReadViewDemo/PDFDemoReaderViewController.swift @@ -1004,6 +1004,12 @@ private final class PDFDemoPageView: UIView, RDPDFReaderPageInteractable, UIGest override var canBecomeFirstResponder: Bool { true } override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { + if tappedHighlight != nil { + return action == #selector(rd_copy_highlight(_:)) + || action == #selector(rd_delete_highlight(_:)) + || action == #selector(rd_annotate_highlight(_:)) + || action == #selector(rd_delete_annotation(_:)) + } guard let selection = textLayer.selectedSelection else { return false } switch action { case #selector(rd_copy(_:)): @@ -1114,16 +1120,6 @@ private final class PDFDemoPageView: UIView, RDPDFReaderPageInteractable, UIGest menuController.setMenuVisible(true, animated: true) } - override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { - if tappedHighlight != nil { - return action == #selector(rd_copy_highlight(_:)) - || action == #selector(rd_delete_highlight(_:)) - || action == #selector(rd_annotate_highlight(_:)) - || action == #selector(rd_delete_annotation(_:)) - } - return super.canPerformAction(action, withSender: sender) - } - @objc private func rd_copy_highlight(_ sender: Any?) { guard let highlight = tappedHighlight, let text = highlight.selectedText?.trimmingCharacters(in: .whitespacesAndNewlines),