PTDocumentViewControllerDelegate

@protocol PTDocumentViewControllerDelegate <NSObject>

The methods declared by the PTDocumentViewControllerDelegate protocol allow the adopting delegate to respond to messages from the PTDocumentViewController class.

  • The document view controller no longer has a valid document, and needs to be closed.

    Declaration

    Objective-C

    - (void)documentViewControllerDidBecomeInvalid:
        (nonnull PTDocumentViewController *)documentViewController;

    Swift

    optional func documentViewControllerDidBecomeInvalid(_ documentViewController: PTDocumentViewController)
  • The document view controller has opened a document.

    Declaration

    Objective-C

    - (void)documentViewControllerDidOpenDocument:
        (nonnull PTDocumentViewController *)documentViewController;

    Swift

    optional func documentViewControllerDidOpenDocument(_ documentViewController: PTDocumentViewController)
  • Called when an error occurs when opening a document.

    Declaration

    Objective-C

    - (void)documentViewController:
                (nonnull PTDocumentViewController *)documentViewController
        didFailToOpenDocumentWithError:(nonnull NSError *)error;

    Swift

    optional func documentViewController(_ documentViewController: PTDocumentViewController, didFailToOpenDocumentWithError error: any Error)
  • This method allows the delegate to control whether a cached document should be exported to a different location and is called after a remote document has been fully downloaded or a non-PDF document has finished converting.

    If this method is not implemented, the cached document will be exported.

    Declaration

    Objective-C

    - (BOOL)documentViewController:
                (nonnull PTDocumentViewController *)documentViewController
        shouldExportCachedDocumentAtURL:(nonnull NSURL *)cachedDocumentUrl;

    Swift

    optional func documentViewController(_ documentViewController: PTDocumentViewController, shouldExportCachedDocumentAt cachedDocumentUrl: URL) -> Bool
  • Implement to override default save location when non-PDFs and remote documents are opened via openDocumentWithURL. If this method is not implemented or nil is returned, the document will be saved to the Documents directory with a unique name.

    Declaration

    Objective-C

    - (nullable NSURL *)documentViewController:(nonnull PTDocumentViewController *)
                                                   documentViewController
                destinationURLForDocumentAtURL:(nonnull NSURL *)sourceUrl;

    Swift

    optional func documentViewController(_ documentViewController: PTDocumentViewController, destinationURLForDocumentAt sourceUrl: URL) -> URL?
  • This method allows the delegate to control whether a cached document should be deleted after it has been exported to a different location.

    If this method is not implemented, the cached document will be deleted.

    Declaration

    Objective-C

    - (BOOL)documentViewController:
                (nonnull PTDocumentViewController *)documentViewController
        shouldDeleteCachedDocumentAtURL:(nonnull NSURL *)cachedDocumentUrl;

    Swift

    optional func documentViewController(_ documentViewController: PTDocumentViewController, shouldDeleteCachedDocumentAt cachedDocumentUrl: URL) -> Bool
  • This method allows the delegate to control whether the text search view controller should be dismissed when the document view controller’s view disappears.

    If this method is not implemented, the text search view controller will be dismissed.

    Declaration

    Objective-C

    - (BOOL)documentViewControllerShouldAutomaticallyDismissSearchViewController:
        (nonnull PTDocumentViewController *)documentViewController;

    Swift

    optional func documentViewControllerShouldAutomaticallyDismissSearch(_ documentViewController: PTDocumentViewController) -> Bool
  • This method is called when the panel is opened.

    Declaration

    Objective-C

    - (void)documentViewController:
                (nonnull PTDocumentViewController *)documentViewController
        didShowLeadingPanelViewController:
            (nonnull UIViewController *)leadingPanelViewController;

    Swift

    optional func documentViewController(_ documentViewController: PTDocumentViewController, didShowLeadingPanelViewController leadingPanelViewController: UIViewController)
  • This method is called when the panel is closed.

    Declaration

    Objective-C

    - (void)documentViewController:
                (nonnull PTDocumentViewController *)documentViewController
        didDismissLeadingPanelViewController:
            (nonnull UIViewController *)leadingPanelViewController;

    Swift

    optional func documentViewController(_ documentViewController: PTDocumentViewController, didDismissLeadingPanelViewController leadingPanelViewController: UIViewController)