简体   繁体   中英

not getting highlight option in “menu” in pdfview in ios swift

在此处输入图片说明

I am getting only these 3 options every time while my whole code is working any help will be appreciated.

let selections = pdfView.currentSelection?.selectionsByLine()
        guard (selections?.first?.pages.first) != nil else { return }
        selections?.forEach({ selection in
            let newAnnotation = PDFAnnotation(bounds: selection.bounds(for: pdfView.currentPage!) ,forType: PDFAnnotationSubtype.highlight ,withProperties: nil)
            // Add additional properties to the annotation
            newAnnotation.color = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)
            self.pdfView.currentPage?.displaysAnnotations = true

            self.pdfView.currentPage?.addAnnotation(newAnnotation)
        })

I'm struggling with this question as well, but cannot find any option to add it to PDFView in iOS. In the end I stumbled on a general method of adding menu-items via the shared UIMenuController class.

let menuItem    = UIMenuItem(title: "Highlight", action: #selector(HighLightHandler.highlightSelection(_:)))
UIMenuController.shared.menuItems = [menuItem]

And handle any the highlight:

@objc func highlightSelection(_ sender: UIMenuItem) {
        //put your highlighting code here
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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