PSPDFAnnotationStateManagerDelegate

Objective-C

@protocol PSPDFAnnotationStateManagerDelegate <NSObject>

Swift

protocol AnnotationStateManagerDelegate : NSObjectProtocol

The annotation state manager delegate is informed of state changes.

Note

The manager class supports registering multiple delegate implementations.
  • Called before the manager’s state and or variant attribute changes. As a convenience it also provides access the current state and variant. If any of the delegates returns NO, the state change won’t be applied.

    Declaration

    Objective-C

    - (BOOL)annotationStateManager:(nonnull PSPDFAnnotationStateManager *)manager
                 shouldChangeState:(nullable PSPDFAnnotationString)currentState
                                to:(nullable PSPDFAnnotationString)proposedState
                           variant:
                               (nullable PSPDFAnnotationVariantString)currentVariant
                                to:(nullable PSPDFAnnotationVariantString)
                                       proposedVariant;

    Swift

    optional func annotationStateManager(_ manager: AnnotationStateManager, shouldChangeState currentState: Annotation.Tool?, to proposedState: Annotation.Tool?, variant currentVariant: Annotation.Variant?, to proposedVariant: Annotation.Variant?) -> Bool
  • Called after the manager’s state and or variant attribute changes. As a convenience it also provides access the previous state and variant for any state-related cleanup.

    Declaration

    Objective-C

    - (void)annotationStateManager:(nonnull PSPDFAnnotationStateManager *)manager
                    didChangeState:(nullable PSPDFAnnotationString)oldState
                                to:(nullable PSPDFAnnotationString)newState
                           variant:(nullable PSPDFAnnotationVariantString)oldVariant
                                to:(nullable PSPDFAnnotationVariantString)
                                       newVariant;

    Swift

    optional func annotationStateManager(_ manager: AnnotationStateManager, didChangeState oldState: Annotation.Tool?, to newState: Annotation.Tool?, variant oldVariant: Annotation.Variant?, to newVariant: Annotation.Variant?)
  • Called when the internal undo state changes (pdfController.undoManager state changes or uncommitted drawing related changes).

    Declaration

    Objective-C

    - (void)annotationStateManager:(nonnull PSPDFAnnotationStateManager *)manager
                didChangeUndoState:(BOOL)undoEnabled
                         redoState:(BOOL)redoEnabled;

    Swift

    optional func annotationStateManager(_ manager: AnnotationStateManager, didChangeUndoState undoEnabled: Bool, redoState redoEnabled: Bool)
  • Called when the annotation state manager would like to show the color palette. This is called when the UIPencilPreferredActionShowColorPalette action is invoked from a UIPencilInteraction.

    A single delegate should implement this and show UI. Multiple delegates trying to show UI are likely to interfere with each other. PSPDFAnnotationToolbar implements this method.

    The implementation would typically call toggleStylePicker:presentationOptions: on the state manager, unless you want to show a custom color/style picker.

    Declaration

    Objective-C

    - (void)annotationStateManagerDidRequestShowingColorPalette:
        (nonnull PSPDFAnnotationStateManager *)manager;

    Swift

    optional func annotationStateManagerDidRequestShowingColorPalette(_ manager: AnnotationStateManager)