How do I select or deselect an annotation programmatically?
Q: How do I select or deselect an annotation programmatically?
You can select an annotation on the PSPDFPageView
by either using selectAnnotation
to select a specific annotation,
or by using selectedAnnotations
, which can be set to an array of annotations that lets you select multiple annotations at once.
Copy
1 2 3 4 5 6 | // Get the current page view. It's usually the first in the array. let pageView = pdfController.visiblePageViews[0] // Select an annotation. pageView.select(inkAnnotation, animated: false) // Select multiple annotations. pageView.selectedAnnotations = [firstAnnotation, secondAnnotation]; |
To deselect all currently selected annotations simply set selectedAnnotations
to an empty array, like this:
1 | pageView.selectedAnnotations = [] |