Apple Pencil Double-Tap Actions

PSPDFKit 8.1 for iOS added built-in support for responding to double-taps on the second-generation Apple Pencil, which is compatible with the third-generation models of iPad Pro.

With PSPDFKit’s default configuration, you don’t need to do anything to enable Apple Pencil actions in your app. If you use a custom tools UI (rather than PSPDFAnnotationToolbar), then you need to implement a delegate method for full support. It is possible to disable or replace PSPDFKit’s handling of Apple Pencil actions.

switchEraser — If the state manager’s current state supports erasing (only ink), then switch to the eraser. If the current state is the eraser and the previous state supports erasing, then switch to the previous state.

switchPrevious — Switches to the state manager’s previous non-nil state, or to nil if the previous state was set twice in a row.

If your tools UI can be shown and hidden, be aware that actions will still be handled while the UI is hidden unless you disable the UIPencilInteraction with its isEnabled property.

Custom Actions

To perform a custom action in response to Apple Pencil double-tap actions, or to use your own implementation of the standard preferred actions, first you should disable PSPDFKit’s built-in handling. This can be done by removing the annotation state manager’s pencilInteraction from its view. Setting the isEnabled property will not work because PSPDFKit may set this property internally.

You can then add your own UIPencilInteraction to the view hierarchy and sets its delegate to your own object. You can see this in action in the CustomPencilInteractionActionExample in the Catalog example app.