Trigger load view in ASViewController if node did load but not the view of the view controller

This commit is contained in:
Michael Schneider
2016-11-23 16:24:59 -08:00
parent aefff563bd
commit 64a316679c

View File

@@ -58,6 +58,21 @@
_selfConformsToRangeModeProtocol = [self conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)];
_nodeConformsToRangeModeProtocol = [_node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)];
_automaticallyAdjustRangeModeBasedOnViewEvents = _selfConformsToRangeModeProtocol || _nodeConformsToRangeModeProtocol;
// In case the node will get loaded
if (_node.nodeLoaded) {
// Node already loaded the view
[self view];
} else {
// If the node didn't load yet add ourselves as on did load observer to laod the view in case the node get's loaded
// before the view controller
__weak __typeof__(self) weakSelf = self;
[_node onDidLoad:^(__kindof ASDisplayNode * _Nonnull node) {
if (weakSelf.viewLoaded == NO) {
[weakSelf view];
}
}];
}
return self;
}