PSPDFThumbnailViewController


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

The thumbnail view controller.

  • Data source to get double page mode.

    Declaration

    Objective-C

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

    Swift

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

    Note

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

    Declaration

    Objective-C

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

    Swift

    @IBOutlet weak var delegate: PSPDFThumbnailViewControllerDelegate? { 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: PSPDFDocument?) -> UICollectionViewCell?
  • Scrolls to specified page in the grid.

    Note

    document is ignored in the default implementation.

    Declaration

    Objective-C

    - (void)scrollToPageAtIndex:(PSPDFPageIndex)pageIndex
                       document:(nullable PSPDFDocument *)document
                       animated:(BOOL)animated;

    Swift

    func scrollToPage(at pageIndex: PageIndex, document: PSPDFDocument?, animated: Bool)
  • 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 (readwrite, copy, nonatomic, null_resettable)
        NSArray<PSPDFThumbnailViewFilter> *filterOptions;

    Swift

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

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        PSPDFThumbnailViewFilter _Nonnull activeFilter;

    Swift

    var activeFilter: PSPDFThumbnailViewFilter { get set }
  • Undocumented

    Declaration

    Objective-C

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

    Swift

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

    See

    -[PSPDFViewModePresenter cellClass]

    Declaration

    Objective-C

    @property (assign, readwrite, 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
  • Subclass to customize thumbnail cell configuration.

    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
  • The segmented control shown at the top, which can be used to filter to only show bookmarked or annotated pages.

    Declaration

    Objective-C

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

    Swift

    var filterSegment: PSPDFThumbnailFilterSegmentedControl? { 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: PSPDFThumbnailViewFilter, 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: PSPDFThumbnailViewFilter) -> String?
  • Updates the view used to display filtering progress to a loading state.

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

    Pass YES 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

    Wether 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

    updateInsetsForTopOverlapHeight:

    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?