PSPDFCollectionViewDelegateThumbnailFlowLayout

@protocol PSPDFCollectionViewDelegateThumbnailFlowLayout <NSObject>

Delegate for the collection view thumbnail flow layout.

  • Asks the delegate for an item size for a given index path.

    Warning

    In multi line mode layouts (i.e. singleLineMode returns NO), collectionView:layout:itemSizeAtIndexPath:completionHandler: takes precedence over this method.

    Declaration

    Objective-C

    - (CGSize)collectionView:(nonnull UICollectionView *)collectionView
                      layout:(nonnull UICollectionViewLayout *)layout
         itemSizeAtIndexPath:(nonnull NSIndexPath *)indexPath;

    Swift

    optional func collectionView(_ collectionView: Any!, layout: Any!, itemSizeAt indexPath: IndexPath) -> CGSize

    Parameters

    collectionView

    The collection view object displaying the item.

    layout

    The collection view layout used for positioning the item.

    indexPath

    The index path of the item.

    Return Value

    The size that the item should be layed out with.

  • Asks the delegate for an item size for a given index path and gives the option to update this size later on once expensive size calculations are finished.

    If you are doing expensive size calculation you can implement this method to immediately return an estimate size and then do your size calculation on a background thread. Once done with the calculation, you can pass the correct height to the layout by calling the completion handler. Continuous calls to the completion handler will be ignored and only the first call will be used to update the size of the item.

    Note

    In case the layout is in single line mode, this method will not be called. Instead, only the method without a completion handler will be called as estimated sizing is not available for this mode.

    Warning

    In multi line mode layouts (i.e. singleLineMode returns NO), this method takes precedence over collectionView:layout:itemSizeAtIndexPath:.

    Declaration

    Objective-C

    - (CGSize)collectionView:(nonnull UICollectionView *)collectionView
                      layout:(nonnull UICollectionViewLayout *)layout
         itemSizeAtIndexPath:(nonnull NSIndexPath *)indexPath
           completionHandler:(nonnull void (^)(CGSize))completionHandler;

    Swift

    optional func collectionView(_ collectionView: Any!, layout: Any!, itemSizeAt indexPath: IndexPath, completionHandler: @escaping (CGSize) -> Void) -> CGSize

    Parameters

    collectionView

    The collection view object displaying the item.

    layout

    The collection view layout used for positioning the item.

    indexPath

    The index path of the item.

    completionHandler

    A completion handler than can optionally be called if you need to do expensive height calculation asynchronously. Can be called from an arbitraty queue.

    Return Value

    The size that the item currently should be layed out with. This can be an estimate in case you use the completion handler.

  • Asks the delegate for the size of the header view in the specified section.

    Declaration

    Objective-C

    - (CGSize)collectionView:(nonnull UICollectionView *)collectionView
                                 layout:(nonnull UICollectionViewLayout *)layout
        referenceSizeForHeaderInSection:(NSInteger)section;

    Swift

    optional func collectionView(_ collectionView: Any!, layout: Any!, referenceSizeForHeaderInSection section: Int) -> CGSize

    Parameters

    collectionView

    The collection view object displaying the header view.

    layout

    The collection view layout used for positioning the header view.

    section

    The section of the header.

    Return Value

    The size the header should have in the layout.