Setting the Initial Page Selection When Sharing
It’s possible to set the initial page selection when sharing a document but still allow the user to choose any pages. You can do this by setting properties on a PDFDocumentSharingViewController
before it appears. Leave all the options available in the sharing configuration.
For example, to initially select the first five pages, use the following code:
let sharingViewController: PDFDocumentSharingViewController = ... sharingViewController.selectedPageSelectionOption = .range sharingViewController.shareablePageRange = NSRange(location: 0, length: 5)
PSPDFDocumentSharingViewController *sharingViewController = ... sharingViewController.selectedPageSelectionOption = PSPDFDocumentSharingPagesOptionRange; sharingViewController.shareablePageRange = NSMakeRange(0, 5);
The shareablePageRange
sets the initial range selected by PSPDFDocumentSharingPagesOptionRange
. If the user changes pages with the picker or chooses a different option, like the current page, then the shareablePageRange
property of PDFDocumentSharingViewController
will be updated.
If you want to initially select only the current page, set selectedPageSelectionOption
to .current
and there won’t be a need to set shareablePageRange
.
This has been tested with PSPDFKit 10.1 for iOS.