This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/ios/knowledge-base/how-do-i-select-or-deselect-an-annotation-programmatically.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. How do I select or deselect an annotation programmatically?

You can select an annotation on the PSPDFPageView either by using select(annotations:presentmenu:animated:) 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:

// Get the current page view. It's usually the first in the array.
let pageView = pdfController.visiblePageViews[0]
// Select an annotation.
pageView.select(annotations: [inkAnnotation], presentMenu: false, animated: false)
// Select multiple annotations.
pageView.selectedAnnotations = [firstAnnotation, secondAnnotation];

To deselect all currently selected annotations, set selectedAnnotations to an empty array, like this:

pageView.selectedAnnotations = []