ASCollectionView Class Reference
| Inherits from | UICollectionView |
|---|---|
| Declared in | ASCollectionView.h |
Overview
Node-based collection view.
ASCollectionView is a version of UICollectionView that uses nodes – specifically, ASCellNode subclasses – with asynchronous pre-rendering instead of synchronously loading UICollectionViewCells.
– tuningParametersForRangeType:
Tuning parameters for a range type.
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeTypeParameters
rangeType |
The range type to get the tuning parameters for. |
|---|
Return Value
A tuning parameter value for the given range type.
Defaults to the render range having one sceenful both leading and trailing and the preload range having two screenfuls in both directions.
Declared In
ASCollectionView.h
– setTuningParameters:forRangeType:
Set the tuning parameters for a range type.
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeTypeParameters
tuningParameters |
The tuning parameters to store for a range type. |
|---|---|
rangeType |
The range type to set the tuning parameters for. |
Declared In
ASCollectionView.h
– initWithFrame:collectionViewLayout:asyncDataFetching:
Initializer.
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout asyncDataFetching:(BOOL)asyncDataFetchingEnabledParameters
frame |
The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization. |
|---|---|
layout |
The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil. |
asyncDataFetchingEnabled |
Enable the data fetching in async mode. |
Discussion
If asyncDataFetching is enabled, the AScollectionView will fetch data through collectionView:numberOfRowsInSection: and
collectionView:nodeForRowAtIndexPath: in async mode from background thread. Otherwise, the methods will be invoked synchronically
from calling thread.
Enabling asyncDataFetching could avoid blocking main thread for ASCellNode allocation, which is frequently reported issue for
large scale data. On another hand, the application code need take the responsibility to avoid data inconsistence. Specifically,
we will lock the data source through collectionViewLockDataSource, and unlock it by collectionViewUnlockDataSource after the data fetching.
The application should not update the data source while the data source is locked, to keep data consistence.
Declared In
ASCollectionView.h
leadingScreensForBatching
The number of screens left to scroll before the delegate -collectionView:beginBatchFetchingWithContext: is called.
@property (nonatomic, assign) CGFloat leadingScreensForBatchingDiscussion
Defaults to one screenful.
Declared In
ASCollectionView.h
– performBatchAnimated:updates:completion:
Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before the update block completes.
- (void)performBatchAnimated:(BOOL)animated updates:(void ( ^ ) ( ))updates completion:(void ( ^ ) ( BOOL ))completionParameters
animated |
NO to disable animations for this batch |
|---|---|
updates |
The block that performs the relevant insert, delete, reload, or move operations. |
completion |
A completion handler block to execute when all of the operations are finished. This block takes a single Boolean parameter that contains the value YES if all of the related animations completed successfully or NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. |
Declared In
ASCollectionView.h
– performBatchUpdates:completion:
Perform a batch of updates asynchronously. This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before update block completes.
- (void)performBatchUpdates:(void ( ^ ) ( ))updates completion:(void ( ^ ) ( BOOL ))completionParameters
updates |
The block that performs the relevant insert, delete, reload, or move operations. |
|---|---|
completion |
A completion handler block to execute when all of the operations are finished. This block takes a single Boolean parameter that contains the value YES if all of the related animations completed successfully or NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. |
Declared In
ASCollectionView.h
– reloadDataWithCompletion:
Reload everything from scratch, destroying the working range and all cached nodes.
- (void)reloadDataWithCompletion:(void ( ^ ) ( ))completionParameters
completion |
block to run on completion of asynchronous loading or nil. If supplied, the block is run on the main thread. |
|---|
Discussion
Warning: This method is substantially more expensive than UICollectionView’s version.
Declared In
ASCollectionView.h
– reloadData
Reload everything from scratch, destroying the working range and all cached nodes.
- (void)reloadDataDiscussion
Warning: This method is substantially more expensive than UICollectionView’s version.
Declared In
ASCollectionView.h
– insertSections:
Inserts one or more sections.
- (void)insertSections:(NSIndexSet *)sectionsParameters
sections |
An index set that specifies the sections to insert. |
|---|
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– deleteSections:
Deletes one or more sections.
- (void)deleteSections:(NSIndexSet *)sectionsParameters
sections |
An index set that specifies the sections to delete. |
|---|
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– reloadSections:
Reloads the specified sections.
- (void)reloadSections:(NSIndexSet *)sectionsParameters
sections |
An index set that specifies the sections to reload. |
|---|
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– moveSection:toSection:
Moves a section to a new location.
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSectionParameters
section |
The index of the section to move. |
|---|---|
newSection |
The index that is the destination of the move for the section. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– insertItemsAtIndexPaths:
Inserts items at the locations identified by an array of index paths.
- (void)insertItemsAtIndexPaths:(NSArray *)indexPathsParameters
indexPaths |
An array of NSIndexPath objects, each representing an item index and section index that together identify an item. |
|---|
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– deleteItemsAtIndexPaths:
Deletes the items specified by an array of index paths.
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPathsParameters
indexPaths |
An array of NSIndexPath objects identifying the items to delete. |
|---|
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– reloadItemsAtIndexPaths:
Reloads the specified items.
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPathsParameters
indexPaths |
An array of NSIndexPath objects identifying the items to reload. |
|---|
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– moveItemAtIndexPath:toIndexPath:
Moves the item at a specified location to a destination location.
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPathParameters
indexPath |
The index path identifying the item to move. |
|---|---|
newIndexPath |
The index path that is the destination of the move for the item. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASCollectionView.h
– nodeForItemAtIndexPath:
Similar to -cellForItemAtIndexPath:.
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPathParameters
indexPath |
The index path of the requested node. |
|---|
Return Value
a node for display at this indexpath.
Declared In
ASCollectionView.h
– visibleNodes
Similar to -visibleCells.
- (NSArray *)visibleNodesReturn Value
an array containing the nodes being displayed on screen.
Declared In
ASCollectionView.h
– calculatedSizeForNodeAtIndexPath:
Query the sized node at indexPath for its calculatedSize.
- (CGSize)calculatedSizeForNodeAtIndexPath:(NSIndexPath *)indexPathParameters
indexPath |
The index path for the node of interest. |
|---|
Declared In
ASCollectionView.h
– scrollDirection
Determines collection view’s current scroll direction. Supports 2-axis collection views.
- (ASScrollDirection)scrollDirectionReturn Value
a bitmask of ASScrollDirection values.
Declared In
ASCollectionView.h
– scrollableDirections
Determines collection view’s scrollable directions.
- (ASScrollDirection)scrollableDirectionsReturn Value
a bitmask of ASScrollDirection values.
Declared In
ASCollectionView.h