How Can I Hide or Customize the Action Sheet When Long-Pressing on a Link?

By default, PSPDFKit shows an action sheet (menu) when long-pressing on a link.

This action sheet shows different options depending on whether the link is a web URL or an internal page link, or if it has some other PDF action. For web URLs, the action sheet allows the user to add the link to Safari Reading List or share it using the share sheet (UIActivityViewController).

You can prevent PSPDFKit from showing this action sheet and even choose to show your own action sheet or another user interface (UI).

  1. Register a subclass of PDFPageView.

  2. Override showLinkPreviewActionSheet(for:from:animated:).

  3. Check whether you want to show the action sheet. Call super if you do. If you don’t want to show the action sheet, don’t call super and instead return false.