Force layout pass in ASViewController viewWillAppear: to trigger automatic subnode management

A measure as well as layout pass is forced this early to get nodes like ASCollectionNode, ASTableNode etc. into the hierarchy before UIKit applies the scroll view inset adjustments, if automatic subnode management is enabled. Otherwise the insets would not be applied.
This commit is contained in:
Michael Schneider
2016-11-18 11:35:45 -08:00
parent 8c778c5410
commit ed4f7eff73

View File

@@ -135,10 +135,11 @@ ASVisibilityDidMoveToParentViewController;
[super viewWillAppear:animated];
_ensureDisplayed = YES;
// We do this early layout because we need to get any ASCollectionNodes etc. into the
// hierarchy before UIKit applies the scroll view inset adjustments, if you are using
// automatic subnode management.
// A measure as well as layout pass is forced this early to get nodes like ASCollectionNode, ASTableNode etc.
// into the hierarchy before UIKit applies the scroll view inset adjustments, if automatic subnode management
// is enabled. Otherwise the insets would not be applied.
[_node layoutThatFits:[self nodeConstrainedSize]];
[_node.view layoutIfNeeded];
[_node recursivelyFetchData];