ASTableView Class Reference
| Inherits from | UITableView |
|---|---|
| Declared in | ASTableView.h |
Overview
Node-based table view.
ASTableView is a version of UITableView that uses nodes – specifically, ASCellNode subclasses – with asynchronous pre-rendering instead of synchronously loading UITableViewCells.
– tuningParametersForRangeType:
Tuning parameters for a range.
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeTypeParameters
rangeType |
The range to get the tuning parameters for. |
|---|
Return Value
A tuning parameter value for the given range.
Defaults to the render range having one sceenful both leading and trailing and the preload range having two screenfuls in both directions.
Declared In
ASTableView.h
– setTuningParameters:forRangeType:
Set the tuning parameters for a range.
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeTypeParameters
tuningParameters |
The tuning parameters to store for a range. |
|---|---|
rangeType |
The range to set the tuning parameters for. |
Declared In
ASTableView.h
– initWithFrame:style:asyncDataFetching:
Initializer.
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style asyncDataFetching:(BOOL)asyncDataFetchingEnabledParameters
frame |
A rectangle specifying the initial location and size of the table view in its superview’s coordinates. The frame of the table view changes as table cells are added and deleted. |
|---|---|
style |
A constant that specifies the style of the table view. See UITableViewStyle for descriptions of valid constants. |
asyncDataFetchingEnabled |
Enable the data fetching in async mode. |
Discussion
If asyncDataFetching is enabled, the ASTableView will fetch data through tableView:numberOfRowsInSection: and
tableView: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 tableViewLockDataSource, and unlock it by tableViewUnlockDataSource after the data fetching.
The application should not update the data source while the data source is locked, to keep data consistence.
Declared In
ASTableView.h
leadingScreensForBatching
The number of screens left to scroll before the delegate -tableView:beginBatchFetchingWithContext: is called.
@property (nonatomic, assign) CGFloat leadingScreensForBatchingDiscussion
Defaults to one screenful.
Declared In
ASTableView.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 UITableView’s version.
Declared In
ASTableView.h
– reloadData
Reload everything from scratch, destroying the working range and all cached nodes.
- (void)reloadDataDiscussion
Warning: This method is substantially more expensive than UITableView’s version.
Declared In
ASTableView.h
– beginUpdates
begins a batch of insert, delete reload and move operations. This method must be called from the main thread.
- (void)beginUpdatesDeclared In
ASTableView.h
– endUpdates
Concludes a series of method calls that insert, delete, select, or reload rows and sections of the table view, with animation enabled and no completion block. You call this method to bracket a series of method calls that begins with beginUpdates and that consists of operations to insert, delete, select, and reload rows and sections of the table view. When you call endUpdates, ASTableView begins animating the operations simultaneously. This method is must be called from the main thread. It’s important to remeber that the ASTableView will be processing the updates asynchronously after this call is completed.
- (void)endUpdatesDeclared In
ASTableView.h
– endUpdatesAnimated:completion:
Concludes a series of method calls that insert, delete, select, or reload rows and sections of the table view. You call this method to bracket a series of method calls that begins with beginUpdates and that consists of operations to insert, delete, select, and reload rows and sections of the table view. When you call endUpdates, ASTableView begins animating the operations simultaneously. This method is must be called from the main thread. It’s important to remeber that the ASTableView will be processing the updates asynchronously after this call and are not guaranteed to be reflected in the ASTableView until the completion block is executed.
- (void)endUpdatesAnimated:(BOOL)animated completion:(void ( ^ ) ( BOOL completed ))completionParameters
animated |
NO to disable all animations. |
|---|---|
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
ASTableView.h
– insertSections:withRowAnimation:
Inserts one or more sections, with an option to animate the insertion.
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animationParameters
sections |
An index set that specifies the sections to insert. |
|---|---|
animation |
A constant that indicates how the insertion is to be animated. See UITableViewRowAnimation. |
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
ASTableView.h
– deleteSections:withRowAnimation:
Deletes one or more sections, with an option to animate the deletion.
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animationParameters
sections |
An index set that specifies the sections to delete. |
|---|---|
animation |
A constant that indicates how the deletion is to be animated. See UITableViewRowAnimation. |
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
ASTableView.h
– reloadSections:withRowAnimation:
Reloads the specified sections using a given animation effect.
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animationParameters
sections |
An index set that specifies the sections to reload. |
|---|---|
animation |
A constant that indicates how the reloading is to be animated. See UITableViewRowAnimation. |
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
ASTableView.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
ASTableView.h
– insertRowsAtIndexPaths:withRowAnimation:
Inserts rows at the locations identified by an array of index paths, with an option to animate the insertion.
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animationParameters
indexPaths |
An array of NSIndexPath objects, each representing a row index and section index that together identify a row. |
|---|---|
animation |
A constant that indicates how the insertion is to be animated. See UITableViewRowAnimation. |
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
ASTableView.h
– deleteRowsAtIndexPaths:withRowAnimation:
Deletes the rows specified by an array of index paths, with an option to animate the deletion.
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animationParameters
indexPaths |
An array of NSIndexPath objects identifying the rows to delete. |
|---|---|
animation |
A constant that indicates how the deletion is to be animated. See UITableViewRowAnimation. |
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
ASTableView.h
– reloadRowsAtIndexPaths:withRowAnimation:
Reloads the specified rows using a given animation effect.
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animationParameters
indexPaths |
An array of NSIndexPath objects identifying the rows to reload. |
|---|---|
animation |
A constant that indicates how the reloading is to be animated. See UITableViewRowAnimation. |
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
ASTableView.h
– moveRowAtIndexPath:toIndexPath:
Moves the row at a specified location to a destination location.
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPathParameters
indexPath |
The index path identifying the row to move. |
|---|---|
newIndexPath |
The index path that is the destination of the move for the row. |
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
ASTableView.h
– nodeForRowAtIndexPath:
Similar to -cellForRowAtIndexPath:.
- (ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPathParameters
indexPath |
The index path of the requested node. |
|---|
Return Value
a node for display at this indexpath.
Declared In
ASTableView.h
– visibleNodes
Similar to -visibleCells.
- (NSArray *)visibleNodesReturn Value
an array containing the nodes being displayed on screen.
Declared In
ASTableView.h
automaticallyAdjustsContentOffset
YES to automatically adjust the contentOffset when cells are inserted or deleted “before” visible cells, maintaining the users' visible scroll position. Currently this feature tracks insertions, moves and deletions of cells, but section edits are ignored.
@property (nonatomic) BOOL automaticallyAdjustsContentOffsetDiscussion
default is NO.
Declared In
ASTableView.h