PSPDFCollectionViewDelegateThumbnailFlowLayout
Objective-C
@protocol PSPDFCollectionViewDelegateThumbnailFlowLayout <NSObject>
Swift
protocol CollectionViewDelegateThumbnailFlowLayout : NSObjectProtocol
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
false
),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: UICollectionView, layout: UICollectionViewLayout, 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 laid 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
false
), this method takes precedence overcollectionView: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: UICollectionView, layout: UICollectionViewLayout, 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 arbitrary queue.
Return Value
The size that the item currently should be laid 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: UICollectionView, layout: UICollectionViewLayout, 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.
-
Asks the delegate for the page mode of a specific item.
Warning
PSPDFThumbnailFlowLayout
currently only supports single, leading and trailing page modes. ReturningPSPDFDocumentViewLayoutPageModeCenter
will trigger an exception.Declaration
Objective-C
- (PSPDFDocumentViewLayoutPageMode) collectionView:(nonnull UICollectionView *)collectionView layout:(nonnull UICollectionViewLayout *)layout pageModeForItemAtIndexPath:(nonnull NSIndexPath *)indexPath;
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 page mode that should be used by the layout.