Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 4c34623

Browse files
committed
Merge branch 'master' into ASVideoNode
2 parents d955911 + df10f8f commit 4c34623

7 files changed

Lines changed: 67 additions & 6 deletions

File tree

AsyncDisplayKit/ASCollectionView.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,17 @@ NS_ASSUME_NONNULL_BEGIN
376376
@optional
377377

378378
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
379-
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
379+
380+
/**
381+
* Informs the delegate that the collection view did remove the provided node from the view hierarchy.
382+
* This may be caused by the node scrolling out of view, or by deleting the item
383+
* or its containing section with @c deleteItemsAtIndexPaths: or @c deleteSections: .
384+
*
385+
* @param collectionView The sender.
386+
* @param node The node which was removed from the view hierarchy.
387+
* @param indexPath The index path at which the node was located before it was removed.
388+
*/
389+
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath;
380390

381391
/**
382392
* Receive a message that the collectionView is near the end of its data set and more data should be fetched if
@@ -406,6 +416,14 @@ NS_ASSUME_NONNULL_BEGIN
406416
*/
407417
- (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView;
408418

419+
/**
420+
* Informs the delegate that the collection view did remove the node which was previously
421+
* at the given index path from the view hierarchy.
422+
*
423+
* This method is deprecated. Use @c collectionView:didEndDisplayingNode:forItemAtIndexPath: instead.
424+
*/
425+
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
426+
409427
@end
410428

411429
/**

AsyncDisplayKit/ASCollectionView.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,18 @@ - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICol
570570
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
571571
{
572572
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
573-
573+
574+
if ([_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNode:forItemAtIndexPath:)]) {
575+
ASCellNode *node = ((_ASCollectionViewCell *)cell).node;
576+
ASDisplayNodeAssertNotNil(node, @"Expected node associated with removed cell not to be nil.");
577+
[_asyncDelegate collectionView:self didEndDisplayingNode:node forItemAtIndexPath:indexPath];
578+
}
579+
#pragma clang diagnostic push
580+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
574581
if ([_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNodeForItemAtIndexPath:)]) {
575582
[_asyncDelegate collectionView:self didEndDisplayingNodeForItemAtIndexPath:indexPath];
576583
}
584+
#pragma clang diagnostic pop
577585
}
578586

579587
- (void)layoutSubviews

AsyncDisplayKit/ASControlNode.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
170170
if (!self.enabled)
171171
return;
172172

173+
// On iPhone 6s, iOS 9.2 (and maybe other versions) sometimes calls -touchesEnded:withEvent:
174+
// twice on the view for one call to -touchesBegan:withEvent:. On ASControlNode, it used to
175+
// trigger an action twice unintentionally. Now, we ignore that event if we're not in a tracking
176+
// state in order to have a correct behavior.
177+
// It might be related to that issue: http://www.openradar.me/22910171
178+
if (!self.tracking)
179+
return;
180+
173181
NSParameterAssert([touches count] == 1);
174182
UITouch *theTouch = [touches anyObject];
175183
CGPoint touchLocation = [theTouch locationInView:self.view];

AsyncDisplayKit/ASTableView.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,17 @@ NS_ASSUME_NONNULL_BEGIN
336336
@optional
337337

338338
- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath;
339-
- (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath;
339+
340+
/**
341+
* Informs the delegate that the table view did remove the provided node from the view hierarchy.
342+
* This may be caused by the node scrolling out of view, or by deleting the row
343+
* or its containing section with @c deleteRowsAtIndexPaths:withRowAnimation: or @c deleteSections:withRowAnimation: .
344+
*
345+
* @param tableView The sender.
346+
* @param node The node which was removed from the view hierarchy.
347+
* @param indexPath The index path at which the node was located before the removal.
348+
*/
349+
- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath;
340350

341351
/**
342352
* Receive a message that the tableView is near the end of its data set and more data should be fetched if necessary.
@@ -365,6 +375,14 @@ NS_ASSUME_NONNULL_BEGIN
365375
*/
366376
- (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView;
367377

378+
/**
379+
* Informs the delegate that the table view did remove the node which was previously
380+
* at the given index path from the view hierarchy.
381+
*
382+
* This method is deprecated. Use @c tableView:didEndDisplayingNode:forRowAtIndexPath: instead.
383+
*/
384+
- (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
385+
368386
@end
369387

370388
@protocol ASTableViewDelegate <ASTableDelegate>

AsyncDisplayKit/ASTableView.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,18 @@ - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell
598598

599599
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
600600

601+
if ([_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNode:forRowAtIndexPath:)]) {
602+
ASCellNode *node = ((_ASTableViewCell *)cell).node;
603+
ASDisplayNodeAssertNotNil(node, @"Expected node associated with removed cell not to be nil.");
604+
[_asyncDelegate tableView:self didEndDisplayingNode:node forRowAtIndexPath:indexPath];
605+
}
606+
607+
#pragma clang diagnostic push
608+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
601609
if ([_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNodeForRowAtIndexPath:)]) {
602610
[_asyncDelegate tableView:self didEndDisplayingNodeForRowAtIndexPath:indexPath];
603611
}
612+
#pragma clang diagnostic pop
604613
}
605614

606615

AsyncDisplayKit/Details/ASDataController.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,8 @@ - (NSUInteger)numberOfSections
900900
- (NSUInteger)numberOfRowsInSection:(NSUInteger)section
901901
{
902902
ASDisplayNodeAssertMainThread();
903-
return [[self completedNodes][section] count];
903+
NSArray *completedNodes = [self completedNodes];
904+
return (section < completedNodes.count) ? [completedNodes[section] count] : 0;
904905
}
905906

906907
- (ASCellNode *)nodeAtIndexPath:(NSIndexPath *)indexPath

AsyncDisplayKit/Details/ASRangeController.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ - (void)_updateVisibleNodeIndexPaths
156156
NSSet *indexPaths = [_layoutController indexPathsForScrolling:_scrollDirection rangeType:rangeType];
157157

158158
// Notify to remove indexpaths that are leftover that are not visible or included in the _layoutController calculated paths
159-
// This value may be nil for the first call of this method.
160-
NSMutableSet *removedIndexPaths = [_rangeTypeIndexPaths[rangeKey] mutableCopy];
159+
NSMutableSet *removedIndexPaths = _rangeIsValid ? [_rangeTypeIndexPaths[rangeKey] mutableCopy] : [NSMutableSet set];
161160
[removedIndexPaths minusSet:indexPaths];
162161
[removedIndexPaths minusSet:visibleNodePathsSet];
163162

0 commit comments

Comments
 (0)