diff --git a/AsyncDisplayKit/ASCellNode.h b/AsyncDisplayKit/ASCellNode.h index edad6c4114..e70d67efb5 100644 --- a/AsyncDisplayKit/ASCellNode.h +++ b/AsyncDisplayKit/ASCellNode.h @@ -99,6 +99,13 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { - (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER; - (void)touchesCancelled:(nullable NSSet *)touches withEvent:(nullable UIEvent *)event ASDISPLAYNODE_REQUIRES_SUPER; +/** + * Called by the system when ASCellNode is used with an ASCollectionNode. It will not be called by ASTableNode. + * When the UICollectionViewLayout object returns a new UICollectionViewLayoutAttributes object, the corresponding ASCellNode will be updated. + * See UICollectionViewCell's applyLayoutAttributes: for a full description. +*/ +- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes; + /** * @abstract Initializes a cell with a given view controller block. * diff --git a/AsyncDisplayKit/ASCellNode.mm b/AsyncDisplayKit/ASCellNode.mm index b2bc73446d..1bc660c41b 100644 --- a/AsyncDisplayKit/ASCellNode.mm +++ b/AsyncDisplayKit/ASCellNode.mm @@ -211,6 +211,11 @@ #pragma clang diagnostic pop +- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes +{ + // To be overriden by subclasses +} + - (void)cellNodeVisibilityEvent:(ASCellNodeVisibilityEvent)event inScrollView:(UIScrollView *)scrollView withCellFrame:(CGRect)cellFrame { // To be overriden by subclasses diff --git a/AsyncDisplayKit/ASCollectionView.mm b/AsyncDisplayKit/ASCollectionView.mm index a7ab280e25..0c979f4320 100644 --- a/AsyncDisplayKit/ASCollectionView.mm +++ b/AsyncDisplayKit/ASCollectionView.mm @@ -58,6 +58,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell"; _node.highlighted = highlighted; } +- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes +{ + [_node applyLayoutAttributes:layoutAttributes]; +} + @end #pragma mark -