PSPDFThumbnailViewController

Objective-C


@interface PSPDFThumbnailViewController
    : UICollectionViewController <
          UICollectionViewDataSource, UICollectionViewDelegate,
          PSPDFViewModePresenter,
          PSPDFCollectionViewDelegateThumbnailFlowLayout, PSPDFOverridable>

Swift

class ThumbnailViewController : UICollectionViewController, UICollectionViewDataSource, UICollectionViewDelegate, ViewModePresenter, CollectionViewDelegateThumbnailFlowLayout, Overridable

The thumbnail view controller.

  • Data source to get double page mode.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<PSPDFPresentationContext> _Nullable dataSource;

    Swift

    @IBOutlet weak var dataSource: PresentationContext? { get set }
  • Delegate for the thumbnail controller.

    Note

    If this instance has been created by PDFViewController the delegate is already linked and should not be changed.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<PSPDFThumbnailViewControllerDelegate> _Nullable delegate;

    Swift

    @IBOutlet weak var delegate: ThumbnailViewControllerDelegate? { get set }
  • Get the cell for certain page. Compensates against open filters.

    Note

    document is ignored in the default implementation.

    Declaration

    Objective-C

    - (nullable UICollectionViewCell *)cellForPageAtIndex:(PSPDFPageIndex)pageIndex
                                                 document:(nullable PSPDFDocument *)
                                                              document;

    Swift

    func cellForPage(at pageIndex: PageIndex, document: Document?) -> UICollectionViewCell?
  • Stops an ongoing scroll animation.

    Declaration

    Objective-C

    - (void)stopScrolling;

    Swift

    func stopScrolling()
  • Call to refresh the results on the view controller for the filter that’s currently applied.

    Declaration

    Objective-C

    - (void)refreshResultsForCurrentFilter;

    Swift

    func refreshResultsForCurrentFilter()
  • Defines the filter options. Set to nil or empty to hide the filter bar. Defaults to PSPDFThumbnailViewFilterShowAll, PSPDFThumbnailViewFilterAnnotations, PSPDFThumbnailViewFilterBookmarks.

    Declaration

    Objective-C

    @property (nonatomic, copy, null_resettable) NSArray<PSPDFThumbnailViewFilter> *filterOptions;

    Swift

    var filterOptions: [ThumbnailViewFilter]! { get set }
  • Currently active filter. Make sure that one is also set in filterOptions.

    Declaration

    Objective-C

    @property (nonatomic, copy) PSPDFThumbnailViewFilter _Nonnull activeFilter;

    Swift

    var activeFilter: ThumbnailViewFilter { get set }
  • Undocumented

    Declaration

    Objective-C

    - (void)setActiveFilter:(PSPDFThumbnailViewFilter)activeFilter animated:(BOOL)animated;

    Swift

    func setActiveFilter(_ activeFilter: ThumbnailViewFilter, animated: Bool)
  • Class used for thumbnails. Defaults to PSPDFThumbnailGridViewCell and customizations should be a subclass of thereof.

    See

    -[PSPDFViewModePresenter cellClass]

    Declaration

    Objective-C

    @property (nonatomic) Class _Nonnull cellClass;

    Swift

    var cellClass: AnyClass { get set }
  • Returns a suitable size for a thumbnail of a page in a given container size.

    Declaration

    Objective-C

    + (CGSize)automaticThumbnailSizeForPageWithSize:(CGSize)pageSize
                                  referencePageSize:(CGSize)referencePageSize
                                      containerSize:(CGSize)containerSize
                                   interitemSpacing:(CGFloat)interitemSpacing;

    Swift

    class func automaticThumbnailSizeForPage(with pageSize: CGSize, referencePageSize: CGSize, containerSize: CGSize, interitemSpacing: CGFloat) -> CGSize
  • Override to customize thumbnail cell configuration. By default, this method sets an imageLoader for the current cell. To use a custom imageLoader, update the property after or instead of calling through to super.

    Declaration

    Objective-C

    - (void)configureCell:(nonnull PSPDFThumbnailGridViewCell *)cell
             forIndexPath:(nonnull NSIndexPath *)indexPath;

    Swift

    func configureCell(_ cell: PSPDFThumbnailGridViewCell, for indexPath: IndexPath)
  • Returns the page for the indexPath. Override if you structure the cells differently.

    Declaration

    Objective-C

    - (PSPDFPageIndex)pageForIndexPath:(nonnull NSIndexPath *)indexPath;

    Swift

    func page(for indexPath: IndexPath) -> PageIndex
  • Retrieves the index path for the passed in page index.

    Declaration

    Objective-C

    - (nullable NSIndexPath *)indexPathForPageAtIndex:(PSPDFPageIndex)pageIndex;

    Swift

    func indexPathForPage(at pageIndex: PageIndex) -> IndexPath?

    Parameters

    pageIndex

    The page index for which the index path is required.

    Return Value

    The index path for the passed in page.

  • The segmented control shown at the top, which can be used to filter to only show bookmarked or annotated pages.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) PSPDFThumbnailFilterSegmentedControl *filterSegment;

    Swift

    var filterSegment: ThumbnailFilterSegmentedControl? { get }
  • The filter segmented control is recreated on changes; to customize subclass this class and override updateFilterSegment.

    Declaration

    Objective-C

    - (void)updateFilterSegment;

    Swift

    func updateFilterSegment()
  • Starts an asynchronous search for the pages on the document available through the filter provided.

    Declaration

    Objective-C

    - (nullable NSProgress *)
           pagesForFilter:(nonnull PSPDFThumbnailViewFilter)filter
        groupingResultsBy:(NSUInteger)groupSize
                   result:(nonnull void (^)(NSIndexSet *_Nonnull))resultHandler
               completion:(nonnull void (^)(BOOL))completion;

    Swift

    func pages(forFilter filter: ThumbnailViewFilter, groupingResultsBy groupSize: UInt, result resultHandler: @escaping (IndexSet) -> Void, completion: @escaping (Bool) -> Void) -> Progress?

    Parameters

    filter

    The filter to be used

    groupSize

    The searching takes batchSize as a cue as to how often to execute the resultHandler callback.

    resultHandler

    Called when results become available.

    completion

    Called when the search has completed.

    Return Value

    NSProgress instance that can be used to track the progress of the

  • Return label when there’s no content for the filter.

    Declaration

    Objective-C

    - (nullable NSString *)emptyContentLabelForFilter:
        (nonnull PSPDFThumbnailViewFilter)filter;

    Swift

    func emptyContentLabel(forFilter filter: ThumbnailViewFilter) -> String?
  • Updates the view used to display filtering progress to a “loading” state.

    Pass false to enter a “finished loading” state (i.e., when no filter is selected).

    Pass true to transition to a “loading state”, which shows a title for the currently applied filter.

    Declaration

    Objective-C

    - (void)refreshLoadingViewWithLoadingState:(BOOL)loading;

    Swift

    func refreshLoadingView(withLoadingState loading: Bool)

    Parameters

    loading

    Whether the view should display a loading indicator.

  • Returns an instance of PSPDFCollectionReusableFilterView for the header of section 0, nil otherwise.

    Override this method if you need to customize the header in ways that UIAppearance does not support or on an instance by instance basis. If, for example, your app has instances of this class that use the sticky header and instances that don’t, you could do the following:

    • (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { PSPDFCollectionReusableFilterView *header = (id)[super collectionView:collectionView viewForSupplementaryElementOfKind:kind atIndexPath:indexPath]; if ([header isKindOfClass:PSPDFCollectionReusableFilterView.class]) { // Sticky header should have a background, regular header should not. // If you use a solid, accented background color for the sticky header, but want a seamless look for the non–sticky header this makes even more sense. header.backgroundStyle = ((PSPDFThumbnailFlowLayout *)self.collectionViewLayout).stickyHeaderEnabled ? PSPDFCollectionReusableFilterViewStyleDarkBlur : PSPDFCollectionReusableFilterViewStyleNone; // Assuming we want the filter element to sit very close to the items: header.filterElementOffset = CGPointMake(0, 10); } return header; }

    See

    stickyHeaderEnabled (PSPDFThumbnailFlowLayout)

    See

    backgroundStyle (PSPDFCollectionReusableFilterView)

    Declaration

    Objective-C

    - (UICollectionReusableView *_Nullable)
                           collectionView:(nonnull UICollectionView *)collectionView
        viewForSupplementaryElementOfKind:(nonnull NSString *)kind
                              atIndexPath:(nonnull NSIndexPath *)indexPath;

    Swift

    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView?