From ea777456b61efdf39966bab5bf5061c9351da16a Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Thu, 21 Apr 2016 14:41:01 -0500 Subject: [PATCH] [ASCellNode] Apply layout delegate behavior in -__setNeedsLayout, not -setNeedsLayout --- AsyncDisplayKit/ASCellNode.h | 15 ++++----------- AsyncDisplayKit/{ASCellNode.m => ASCellNode.mm} | 5 +++-- 2 files changed, 7 insertions(+), 13 deletions(-) rename AsyncDisplayKit/{ASCellNode.m => ASCellNode.mm} (99%) diff --git a/AsyncDisplayKit/ASCellNode.h b/AsyncDisplayKit/ASCellNode.h index e38376bee4..93de119cb8 100644 --- a/AsyncDisplayKit/ASCellNode.h +++ b/AsyncDisplayKit/ASCellNode.h @@ -34,6 +34,10 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) { /** * Generic cell node. Subclass this instead of `ASDisplayNode` to use with `ASTableView` and `ASCollectionView`. + + * @note When a cell node is contained inside a collection view (or table view), + * calling `-setNeedsLayout` will also notify the collection on the main thread + * so that the collection can update its item layout if the cell's size changed. */ @interface ASCellNode : ASDisplayNode @@ -85,17 +89,6 @@ 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; -/** - * Marks the node as needing layout. Convenience for use whether the view / layer is loaded or not. - * - * If this node was measured, calling this method triggers an internal relayout: the calculated layout is invalidated, - * and the supernode is notified or (if this node is the root one) a full measurement pass is executed using the old constrained size. - * The delegate will then be notified on main thread. - * - * This method can be called inside of an animation block (to animate all of the layout changes). - */ -- (void)setNeedsLayout; - /** * @abstract Initializes a cell with a given view controller block. * diff --git a/AsyncDisplayKit/ASCellNode.m b/AsyncDisplayKit/ASCellNode.mm similarity index 99% rename from AsyncDisplayKit/ASCellNode.m rename to AsyncDisplayKit/ASCellNode.mm index b83c569226..b1971fafe6 100644 --- a/AsyncDisplayKit/ASCellNode.m +++ b/AsyncDisplayKit/ASCellNode.mm @@ -10,6 +10,7 @@ #import "ASInternalHelpers.h" #import "ASEqualityHelpers.h" +#import "ASDisplayNodeInternal.h" #import #import #import @@ -120,10 +121,10 @@ ASDisplayNodeAssert(!layerBacked, @"ASCellNode does not support layer-backing."); } -- (void)setNeedsLayout +- (void)__setNeedsLayout { CGSize oldSize = self.calculatedSize; - [super setNeedsLayout]; + [super __setNeedsLayout]; [self didRelayoutFromOldSize:oldSize toNewSize:self.calculatedSize]; }