diff --git a/AsyncDisplayKit/ASDisplayNode+Beta.h b/AsyncDisplayKit/ASDisplayNode+Beta.h index b4c2042a24..2642ba3f50 100644 --- a/AsyncDisplayKit/ASDisplayNode+Beta.h +++ b/AsyncDisplayKit/ASDisplayNode+Beta.h @@ -50,10 +50,18 @@ - (void)didCompleteLayoutTransition:(id)context; /** - * @abstract Invalidates the current layout and begins a relayout of the node to the new layout returned in `calculateLayoutThatFits:`. + * @abstract Transitions the current layout with a new constrained size. * - * @discussion Animation is optional, but will still proceed through the `transitionLayout` methods with `isAnimated == NO`. + * @discussion Animation is optional, but will still proceed through your `animateLayoutTransition` implementation with `isAnimated == NO`. + * If the passed constrainedSize is the the same as the node's current constrained size, this method is noop. */ - (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated; +/** + * @abstract Invalidates the current layout and begins a relayout of the node with the current `constrainedSize`. + * + * @discussion Animation is optional, but will still proceed through your `animateLayoutTransition` implementation with `isAnimated == NO`. + */ +- (ASLayout *)transitionLayoutWithAnimation:(BOOL)animated; + @end diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 163ca6adeb..ae39983c8e 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -675,9 +675,14 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) return _pendingLayout; } -- (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated +- (ASLayout *)transitionLayoutWithAnimation:(BOOL)animated { [self invalidateCalculatedLayout]; + [self transitionLayoutWithSizeRange:_constrainedSize animated:animated]; +} + +- (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated +{ return [self measureWithSizeRange:constrainedSize completion:^{ _transitionContext = [[_ASTransitionContext alloc] initWithLayout:_pendingLayout constrainedSize:constrainedSize diff --git a/AsyncDisplayKit/ASViewController.m b/AsyncDisplayKit/ASViewController.m index 63d9f3e566..4e93b70343 100644 --- a/AsyncDisplayKit/ASViewController.m +++ b/AsyncDisplayKit/ASViewController.m @@ -59,6 +59,9 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + + [_node measureWithSizeRange:[self nodeConstrainedSize]]; + _ensureDisplayed = YES; [_node recursivelyFetchData]; }