PSPDFDrawViewDelegate

Objective-C

@protocol PSPDFDrawViewDelegate <NSObject>

Swift

protocol DrawViewDelegate : NSObjectProtocol

A delegate that is notified when the draw view begins or ends drawing a stroke. The implementation of these calls should persist the annotation changes to the document as well as recording the changes for undo.

  • Called when the draw view detects a touch and begins drawing or erasing an annotation. This is the suggested place to begin recording an undo command.

    Declaration

    Objective-C

    - (void)drawView:(nonnull PSPDFDrawView *)drawView
        didBeginDrawingInMode:(PSPDFDrawViewInputMode)inputMode;

    Swift

    func drawView(_ drawView: DrawView, didBeginDrawingIn inputMode: DrawView.InputMode)

    Parameters

    drawView

    The draw view in which the drawing is being carried out.

    inputMode

    Whether the draw view is adding a new stroke or performing erasing.

  • Called when the draw view finishes drawing or erasing an annotation. This is the suggested place to commit recording an undo command.

    Declaration

    Objective-C

    - (void)drawView:(nonnull PSPDFDrawView *)drawView
        didEndDrawingInMode:(PSPDFDrawViewInputMode)inputMode
                   finished:(BOOL)didFinish;

    Swift

    func drawView(_ drawView: DrawView, didEndDrawingIn inputMode: DrawView.InputMode, finished didFinish: Bool)

    Parameters

    drawView

    The draw view in which the drawing is being carried out.

    inputMode

    Whether the draw view was adding a new stroke or performing erasing.

    didFinish

    Whether the drawing stroke was carried out successfully. false when the drawing stroke fails or is cancelled.

  • The draw view is asking the delegate to add an annotation to the document. This is also the suggested place to record an undo command for adding the annotation.

    Declaration

    Objective-C

    - (void)drawView:(nonnull PSPDFDrawView *)drawView
        wantsToAddAnnotation:(nonnull PSPDFAnnotation *)annotation;

    Swift

    func drawView(_ drawView: DrawView, wantsToAdd annotation: Annotation)

    Parameters

    drawView

    The draw view in which the annotation was drawn.

    annotation

    The annotation that should be added to the document.

  • The draw view is asking the delegate to modify an annotation using the given block. This can be in the form of appending a stroke or erasing. This is also the suggested place to record an undo command for changing the annotation.

    Declaration

    Objective-C

    - (void)drawView:(nonnull PSPDFDrawView *)drawView
        wantsToModifyAnnotation:(nonnull PSPDFAnnotation *)annotation
                        inScope:(nonnull void (^)(void))scope;

    Swift

    func drawView(_ drawView: DrawView, wantsToModifyAnnotation annotation: Annotation, inScope scope: @escaping () -> Void)

    Parameters

    drawView

    The draw view in which the annotation is drawn.

    annotation

    The annotation that should be modified.

    scope

    The block that modifies annotation. The delegate is responsible for executing it.

  • The draw view is asking the delegate to delete an annotation from the document. This is also the suggested place to record an undo command for deleting the annotation.

    Declaration

    Objective-C

    - (void)drawView:(nonnull PSPDFDrawView *)drawView
        wantsToDeleteAnnotation:(nonnull PSPDFAnnotation *)annotation;

    Swift

    func drawView(_ drawView: DrawView, wantsToDelete annotation: Annotation)

    Parameters

    drawView

    The draw view in which the annotation was deleted.

    annotation

    The annotation that should be deleted from the document.