From 46421f868437371255f5fc0a7f337b0980888956 Mon Sep 17 00:00:00 2001 From: Hannah Troisi Date: Fri, 17 Jun 2016 10:17:52 -0700 Subject: [PATCH 1/2] [ASCollectionView] support UICollectionViewLayoutAttributes --- AsyncDisplayKit/ASCellNode.h | 2 ++ AsyncDisplayKit/ASCellNode.mm | 4 ++++ AsyncDisplayKit/ASCollectionView.mm | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/AsyncDisplayKit/ASCellNode.h b/AsyncDisplayKit/ASCellNode.h index edad6c4114..3cdae7deae 100644 --- a/AsyncDisplayKit/ASCellNode.h +++ b/AsyncDisplayKit/ASCellNode.h @@ -99,6 +99,8 @@ 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; +- (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..cfd0090766 100644 --- a/AsyncDisplayKit/ASCellNode.mm +++ b/AsyncDisplayKit/ASCellNode.mm @@ -211,6 +211,10 @@ #pragma clang diagnostic pop +- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes +{ +} + - (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 821e21ddca..54dfe8a433 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 - From da27d36b4abfce74a190337e7236116b037ab713 Mon Sep 17 00:00:00 2001 From: Hannah Troisi Date: Sat, 18 Jun 2016 12:54:55 -0700 Subject: [PATCH 2/2] Add comments --- AsyncDisplayKit/ASCellNode.h | 5 +++++ AsyncDisplayKit/ASCellNode.mm | 1 + 2 files changed, 6 insertions(+) diff --git a/AsyncDisplayKit/ASCellNode.h b/AsyncDisplayKit/ASCellNode.h index 3cdae7deae..e70d67efb5 100644 --- a/AsyncDisplayKit/ASCellNode.h +++ b/AsyncDisplayKit/ASCellNode.h @@ -99,6 +99,11 @@ 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; /** diff --git a/AsyncDisplayKit/ASCellNode.mm b/AsyncDisplayKit/ASCellNode.mm index cfd0090766..1bc660c41b 100644 --- a/AsyncDisplayKit/ASCellNode.mm +++ b/AsyncDisplayKit/ASCellNode.mm @@ -213,6 +213,7 @@ - (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes { + // To be overriden by subclasses } - (void)cellNodeVisibilityEvent:(ASCellNodeVisibilityEvent)event inScrollView:(UIScrollView *)scrollView withCellFrame:(CGRect)cellFrame