Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pager node for interface coalescing #877

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 6 additions & 0 deletions Source/ASDisplayNode+Subclasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 10 additions & 0 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,8 @@ - (void)__enterHierarchy
}

__instanceLock__.unlock();

[self didEnterHierarchy];
}

- (void)__exitHierarchy
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 3 additions & 5 deletions Source/ASPagerNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down