ASCollectionView Class Reference
Inherits from | UICollectionView |
---|---|
Declared in | ASCollectionView.h |
Overview
Asynchronous UICollectionView with Intelligent Preloading capabilities.
ASCollectionView is a true subclass of UICollectionView, meaning it is pointer-compatible with code that currently uses UICollectionView.
The main difference is that asyncDataSource expects -nodeForItemAtIndexPath, an ASCellNode, and the sizeForItemAtIndexPath: method is eliminated (as are the performance problems caused by it). This is made possible because ASCellNodes can calculate their own size, and preload ahead of time.
Note: ASCollectionNode is strongly recommended over ASCollectionView. This class exists for adoption convenience.
asyncDelegate
The object that acts as the asynchronous delegate of the collection view
@property (nonatomic, weak) id<ASCollectionDelegate> asyncDelegate
Discussion
The delegate must adopt the ASCollectionDelegate protocol. The collection view maintains a weak reference to the delegate object.
The delegate object is responsible for providing size constraints for nodes and indicating whether batch fetching should begin.
Declared In
ASCollectionView.h
asyncDataSource
The object that acts as the asynchronous data source of the collection view
@property (nonatomic, weak) id<ASCollectionDataSource> asyncDataSource
Discussion
The datasource must adopt the ASCollectionDataSource protocol. The collection view maintains a weak reference to the datasource object.
The datasource object is responsible for providing nodes or node creation blocks to the collection view.
Declared In
ASCollectionView.h
collectionNode
Returns the corresponding ASCollectionNode
@property (nonatomic, weak, readonly) ASCollectionNode *collectionNode
Return Value
collectionNode The corresponding ASCollectionNode, if one exists.
Declared In
ASCollectionView.h
leadingScreensForBatching
The number of screens left to scroll before the delegate -collectionView:beginBatchFetchingWithContext: is called.
@property (nonatomic, assign) CGFloat leadingScreensForBatching
Discussion
Defaults to two screenfuls.
Declared In
ASCollectionView.h
layoutInspector
Optional introspection object for the collection view’s layout.
@property (nonatomic, weak) id<ASCollectionViewLayoutInspecting> layoutInspector
Discussion
Since supplementary and decoration views are controlled by the collection view’s layout, this object
is used as a bridge to provide information to the internal data controller about the existence of these views and
their associated index paths. For collection views using UICollectionViewFlowLayout
, a default inspector
implementation ASCollectionViewFlowLayoutInspector
is created and set on this property by default. Custom
collection view layout subclasses will need to provide their own implementation of an inspector object for their
supplementary views to be compatible with ASCollectionView
’s supplementary node support.
Declared In
ASCollectionView.h
– nodeForItemAtIndexPath:
Retrieves the node for the item at the given index path.
- (nullable ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
Parameters
indexPath |
The index path of the requested node. |
---|
Return Value
The node at the given index path, or @c nil if no item exists at the specified path.
Declared In
ASCollectionView.h
– supplementaryNodeForElementKind:atIndexPath:
Similar to -supplementaryViewForElementKind:atIndexPath:
- (nullable ASCellNode *)supplementaryNodeForElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
Parameters
elementKind |
The kind of supplementary node to locate. |
---|---|
indexPath |
The index path of the requested supplementary node. |
Return Value
The specified supplementary node or @c nil.
Declared In
ASCollectionView.h
– contextForSection:
Retrieves the context object for the given section, as provided by the data source in the @c collectionNode:contextForSection: method. This method must be called on the main thread.
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section
Parameters
section |
The section to get the context for. |
---|
Return Value
The context object, or @c nil if no context was provided.
Declared In
ASCollectionView.h
scrollDirection
Determines collection view’s current scroll direction. Supports 2-axis collection views.
@property (nonatomic, readonly) ASScrollDirection scrollDirection
Return Value
a bitmask of ASScrollDirection values.
Declared In
ASCollectionView.h
scrollableDirections
Determines collection view’s scrollable directions.
@property (nonatomic, readonly) ASScrollDirection scrollableDirections
Return Value
a bitmask of ASScrollDirection values.
Declared In
ASCollectionView.h
zeroContentInsets
Forces the .contentInset to be UIEdgeInsetsZero.
@property (nonatomic) BOOL zeroContentInsets
Discussion
By default, UIKit sets the top inset to the navigation bar height, even for horizontally scrolling views. This can only be disabled by setting a property on the containing UIViewController, automaticallyAdjustsScrollViewInsets, which may not be accessible. ASPagerNode uses this to ensure its flow layout behaves predictably and does not log undefined layout warnings.
Declared In
ASCollectionView.h