Added node access methods to ASTableView, ASCollectionView.

This commit is contained in:
Dustin Shahidehpour
2015-01-26 13:57:04 -08:00
parent e1f8342c3b
commit 94cd785870
6 changed files with 78 additions and 2 deletions

View File

@@ -1 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:AsyncDisplayKit.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/></Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:AsyncDisplayKit.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -63,6 +63,22 @@
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths;
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
/**
* Similar to -cellForItemAtIndexPath:.
*
* @param indexPath The index path of the requested node.
*
* @returns a node for display at this indexpath.
*/
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath;
/**
* Similar to -visibleCells.
*
* @returns an array containing the nodes being displayed on screen.
*/
- (NSArray *)visibleNodes;
/**
* Query the sized node at `indexPath` for its calculatedSize.
*

View File

@@ -196,6 +196,19 @@ static BOOL _isInterceptedSelector(SEL sel)
return [[_dataController nodeAtIndexPath:indexPath] calculatedSize];
}
- (NSArray *)visibleNodes
{
NSArray *indexPaths = [self indexPathsForVisibleItems];
NSMutableArray *visibleNodes = [[NSMutableArray alloc] init];
[indexPaths enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
ASCellNode *visibleNode = [self nodeForItemAtIndexPath:obj];
[visibleNodes addObject:visibleNode];
}];
return visibleNodes;
}
#pragma mark Assertions.
- (void)insertSections:(NSIndexSet *)sections
@@ -238,6 +251,10 @@ static BOOL _isInterceptedSelector(SEL sel)
[_dataController moveRowAtIndexPath:indexPath toIndexPath:newIndexPath withAnimationOption:kASCollectionViewAnimationNone];
}
- (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [_dataController nodeAtIndexPath:indexPath];
}
#pragma mark -
#pragma mark Intercepted selectors.

View File

@@ -72,6 +72,22 @@
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
/**
* Similar to -cellForRowAtIndexPath:.
*
* @param indexPath The index path of the requested node.
*
* @returns a node for display at this indexpath.
*/
- (ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath;
/**
* Similar to -visibleCells.
*
* @returns an array containing the nodes being displayed on screen.
*/
- (NSArray *)visibleNodes;
@end

View File

@@ -198,6 +198,24 @@ static BOOL _isInterceptedSelector(SEL sel)
_layoutController.tuningParameters = tuningParameters;
}
- (ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [_dataController nodeAtIndexPath:indexPath];
}
- (NSArray *)visibleNodes
{
NSArray *indexPaths = [self indexPathsForVisibleRows];
NSMutableArray *visibleNodes = [[NSMutableArray alloc] init];
[indexPaths enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
ASCellNode *visibleNode = [self nodeForRowAtIndexPath:obj];
[visibleNodes addObject:visibleNode];
}];
return visibleNodes;
}
#pragma mark Assertions.
- (void)throwUnimplementedException

View File

@@ -7,4 +7,4 @@ DEPENDENCIES:
SPEC CHECKSUMS:
OCMock: 6db79185520e24f9f299548f2b8b07e41d881bd5
COCOAPODS: 0.34.4
COCOAPODS: 0.35.0