diff --git a/CHANGELOG.md b/CHANGELOG.md index b3057240b..5b977e493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## master * Add your own contributions to the next release on the line below this with your name. +- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877) - [ASTextNode2] Upgrade lock safety by protecting all ivars (including rarely-changed ones). - User FLT_EPSILON in ASCeilPixelValue and ASFloorPixelValue to help with floating point precision errors when computing layouts for 3x devices. [Ricky Cancro](https://github.com/rcancro) [#838](https://github.com/TextureGroup/Texture/pull/864) - Disable interface colescing and match to pre-colescing interface update behavior [Max Wang](https://github.com/wsdwsd0829) [#862](https://github.com/TextureGroup/Texture/pull/862) diff --git a/Source/ASDisplayNode+Subclasses.h b/Source/ASDisplayNode+Subclasses.h index 3b7b7d0d5..5f7abcdb2 100644 --- a/Source/ASDisplayNode+Subclasses.h +++ b/Source/ASDisplayNode+Subclasses.h @@ -362,6 +362,12 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)didExitHierarchy ASDISPLAYNODE_REQUIRES_SUPER; +/** + * Called just after the view is added to a window. + * Note: this may be called multiple times during view controller transitions. To overcome this: use didEnterVisibleState or its equavalents. + */ +- (void)didEnterHierarchy ASDISPLAYNODE_REQUIRES_SUPER; + /** * @abstract Whether the view or layer of this display node is currently in a window */ diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index ed8f4a421..102be6d4e 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -2876,6 +2876,8 @@ - (void)__enterHierarchy } __instanceLock__.unlock(); + + [self didEnterHierarchy]; } - (void)__exitHierarchy @@ -2996,6 +2998,14 @@ - (void)willEnterHierarchy } } +- (void)didEnterHierarchy { + ASDisplayNodeAssertMainThread(); + ASDisplayNodeAssert(!_flags.isEnteringHierarchy, @"You should never call -didEnterHierarchy directly. Appearance is automatically managed by ASDisplayNode"); + ASDisplayNodeAssert(!_flags.isExitingHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); + ASDisplayNodeAssert(_flags.isInHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); + ASDisplayNodeAssertLockUnownedByCurrentThread(__instanceLock__); +} + - (void)didExitHierarchy { ASDisplayNodeAssertMainThread(); diff --git a/Source/ASPagerNode.m b/Source/ASPagerNode.m index 719a45687..d2452e6f7 100644 --- a/Source/ASPagerNode.m +++ b/Source/ASPagerNode.m @@ -221,14 +221,12 @@ - (void)proxyTargetHasDeallocated:(ASDelegateProxy *)proxy [self setDelegate:nil]; } -- (void)didEnterVisibleState +- (void)didEnterHierarchy { - [super didEnterVisibleState]; + [super didEnterHierarchy]; // Check that our view controller does not automatically set our content insets - // It would be better to have a -didEnterHierarchy hook to put this in, but - // such a hook doesn't currently exist, and in every use case I can imagine, - // the pager is not hosted inside a range-managed node. + // In every use case I can imagine, the pager is not hosted inside a range-managed node. if (_allowsAutomaticInsetsAdjustment == NO) { UIViewController *vc = [self.view asdk_associatedViewController]; if (vc.automaticallyAdjustsScrollViewInsets) {