Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Minor fixes in ASViewController:
Browse files Browse the repository at this point in the history
- If its node isn't provided by users, don't replace the view controller's view with the node's view because it might be loaded from a nib.
- Init a vanilla ASDisplayNode if a node isn't provided.
  • Loading branch information
nguyenhuy committed Dec 21, 2016
1 parent 510ce09 commit 8969e1a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions AsyncDisplayKit/ASViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

@implementation ASViewController
{
BOOL _nodeProvided;
BOOL _ensureDisplayed;
BOOL _automaticallyAdjustRangeModeBasedOnViewEvents;
BOOL _parentManagesVisibilityDepth;
Expand All @@ -38,9 +39,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
return nil;
}

_node = [[ASDisplayNode alloc] initWithViewBlock:^UIView * _Nonnull{
return [[UIView alloc] init];
}];
_node = [[ASDisplayNode alloc] init];
[self _initializeInstance];

return self;
Expand All @@ -52,9 +51,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder
return nil;
}

_node = [[ASDisplayNode alloc] initWithViewBlock:^UIView * _Nonnull{
return [[UIView alloc] init];
}];
_node = [[ASDisplayNode alloc] init];
[self _initializeInstance];

return self;
Expand All @@ -66,6 +63,7 @@ - (instancetype)initWithNode:(ASDisplayNode *)node
return nil;
}

_nodeProvided = YES;
_node = node;
[self _initializeInstance];

Expand Down Expand Up @@ -104,14 +102,16 @@ - (void)dealloc

- (void)loadView
{
ASDisplayNodeAssertTrue(!_node.layerBacked);

// Apple applies a frame and autoresizing masks we need. Allocating a view is not
// nearly as expensive as adding and removing it from a hierarchy, and fortunately
// we can avoid that here. Enabling layerBacking on a single node in the hierarchy
// will have a greater performance benefit than the impact of this transient view.
[super loadView];

if (!_nodeProvided) { return; }

ASDisplayNodeAssertTrue(!_node.layerBacked);

UIView *view = self.view;
CGRect frame = view.frame;
UIViewAutoresizing autoresizingMask = view.autoresizingMask;
Expand Down

0 comments on commit 8969e1a

Please sign in to comment.