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 14 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
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 it's equavalents.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: or its equivalents, no apostrophe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
- (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 -willEnterHierarchy directly. Appearance is automatically managed by ASDisplayNode");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update. comment You should never call -didEnterHierarchy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

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