Disabling Automatic Opening of Comments

By default, tapping a note annotation in a regular-width trait environment will automatically display the comments associated with that annotation in a popover presentation.

To prevent the note annotations from opening the comments automatically, implement the pdfViewController(_:didTapOn:annotationPoint:annotationView:pageView:viewPoint:) delegate method and use select(annotations:presentMenu:animated:) to programmatically select note annotations:

func pdfViewController(_ pdfController: PDFViewController, didTapOn annotation: Annotation, annotationPoint: CGPoint, annotationView: (UIView & AnnotationPresenting)?, pageView: PDFPageView, viewPoint: CGPoint) -> Bool {
    if annotation is NoteAnnotation {
        pageView.select(annotations: [annotation], presentMenu: true, animated: true)
        return true
    } else {
        return false
    }
}

With the customization from above in place, tapping a note annotation will bring up the annotation selection menu instead, which will require tapping on the Comments menu item to bring up the NoteAnnotationViewController again.

Refer to our handling user interactions guide to learn more about customizing different aspects of how your users interact with annotations.