1

可以添加 GestureRecognizer 或设置为 PDFAnnotation

  func setDocumentAnnotation() {
    let anotation:PDFAnnotation = PDFAnnotation(bounds: CGRect(x: pointX, y: pointY, width: pointW, height: pointH), forType: .highlight, withProperties: nil)
        anotation.color = .yellow
        anotation.endLineStyle = .circle
        guard let page = pdfView.currentPage else {return}
        page.addAnnotation(anotation)
}


 @objc func annotationTapping(_ sender: UITapGestureRecognizer){
    print("------- annotationTapping ------")
}
4

2 回答 2

5

希望这个方法对你有用..

 NotificationCenter.default.addObserver(self, selector: #selector (titleTapped), name:Notification.Name.PDFViewAnnotationHit , object: nil)

  @objc func titleTapped()  {
       -Provide the action you want---
    }
于 2018-12-30T00:57:49.090 回答
4

无法将手势识别器添加到注释本身。但是,您可以将其添加到PDFView然后检查用户是否点击了注释。这是一个简单的片段:

let tappedPage = pdfView.page(for: tapLocation, nearest: false)
if let page = tappedPage {
    let tapPageLocation = pdfView.convert(tapLocation, to: page)
    let annotation = page.annotation(at: tapPageLocation)
}

我希望这有帮助。

于 2018-03-08T13:35:29.073 回答