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 orvariant
attribute changes. As a convenience it also provides access the currentstate
andvariant
. If any of the delegates returnsfalse
, 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 orvariant
attribute changes. As a convenience it also provides access the previousstate
andvariant
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 state of undo or redo 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 aUIPencilInteraction
.A single delegate should implement this and show UI. Multiple delegates trying to show UI are likely to interfere with each other.
AnnotationToolbar
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)