Annotation State Manager

PSPDFAnnotationStateManager is responsible for for all state related to annotation creation in a PSPDFViewController.

Don't create an instance of PSPDFAnnotationStateManager yourself, use annotationStateManager exposed in PSPDFViewController.

Using PSPDFAnnotationStateManager you can programmatically set or toggle all the different states used for annotation creation. Additionally, PSPDFAnnotationToolbar toggles annotation states, when tapping annotation tools, using PSPDFAnnotationStateManager internally as well. Therefore, programmatically toggling a state, is automatically represented on the annotation toolbar, if it's visible.

Custom Annotation User Interface

If you don't want to use PSPDFAnnotationToolbar, but instead provide your own user interface related to annotations, PSPDFAnnotationStateManager is the class you want to use to connect your user interface to PSPDFKit.

Customize Behavior

You can also customize the behavior when showing the annotation toolbar, to automatically select an annotation tool to immediately start drawing. This can be done by setting a state using PSPDFAnnotationStateManager when the toolbar is made visible. This can be enabled using the following code snippet:

Copy
1
2
3
4
5
6
self.annotationToolbarController?.annotationToolbar.toolbarDelegate = self

// PSPDFFlexibleToolbarDelegate
func flexibleToolbarWillShow(_ toolbar: PSPDFFlexibleToolbar) {
    self.annotationStateManager.setState(.ink, variant: .inkVariantPen)
}
Copy
1
2
3
4
5
6
self.annotationToolbarController.annotationToolbar.toolbarDelegate = self;

// PSPDFFlexibleToolbarDelegate
- (void)flexibleToolbarWillShow:(PSPDFFlexibleToolbar *)toolbar {
    [self.annotationStateManager setState:PSPDFAnnotationStringInk variant:PSPDFAnnotationStringInkVariantPen];
}