From 5687c651bcc4c680f1c398c1e7db05edc3ed0f57 Mon Sep 17 00:00:00 2001 From: Scott Goodson Date: Thu, 3 Mar 2016 18:04:05 -0800 Subject: [PATCH 1/2] [ASViewController] Call -[super loadView] in order to harvest frame value and apply it to node's view. --- AsyncDisplayKit/ASViewController.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASViewController.m b/AsyncDisplayKit/ASViewController.m index baca8d2cbf..3678d99a22 100644 --- a/AsyncDisplayKit/ASViewController.m +++ b/AsyncDisplayKit/ASViewController.m @@ -49,7 +49,21 @@ - (void)loadView { ASDisplayNodeAssertTrue(!_node.layerBacked); - self.view = _node.view; + + // 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]; + UIView *view = self.view; + CGRect frame = view.frame; + UIViewAutoresizing autoresizingMask = view.autoresizingMask; + + // We have what we need, so now create and assign the view we actually want. + view = _node.view; + self.view = view; + _node.frame = frame; + _node.autoresizingMask = autoresizingMask; } - (void)viewWillLayoutSubviews From 2a5464356fc0b150245021466b4a4f542ce6a950 Mon Sep 17 00:00:00 2001 From: Scott Goodson Date: Thu, 3 Mar 2016 18:04:05 -0800 Subject: [PATCH 2/2] [ASViewController] Call -[super loadView] in order to harvest frame value and apply it to node's view. --- AsyncDisplayKit/ASViewController.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASViewController.m b/AsyncDisplayKit/ASViewController.m index baca8d2cbf..8e35132475 100644 --- a/AsyncDisplayKit/ASViewController.m +++ b/AsyncDisplayKit/ASViewController.m @@ -49,7 +49,21 @@ - (void)loadView { ASDisplayNodeAssertTrue(!_node.layerBacked); - self.view = _node.view; + + // 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]; + UIView *view = self.view; + CGRect frame = view.frame; + UIViewAutoresizing autoresizingMask = view.autoresizingMask; + + // We have what we need, so now create and assign the view we actually want. + view = _node.view; + _node.frame = frame; + _node.autoresizingMask = autoresizingMask; + self.view = view; } - (void)viewWillLayoutSubviews