From 057c48482ad463910c5e8a89c2bb772216920d3c Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Fri, 24 Jun 2016 20:59:07 -0700 Subject: [PATCH] Fix Modal presented ASViewController don't rotate on iOS 8.3 --- AsyncDisplayKit/ASViewController.mm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASViewController.mm b/AsyncDisplayKit/ASViewController.mm index 4dc56942f3..efa7009557 100644 --- a/AsyncDisplayKit/ASViewController.mm +++ b/AsyncDisplayKit/ASViewController.mm @@ -89,6 +89,20 @@ { [super viewWillLayoutSubviews]; [_node measureWithSizeRange:[self nodeConstrainedSize]]; + + if (!AS_AT_LEAST_IOS9) { + [self _legacyHandleViewDidLayoutSubviews]; + } +} + +- (void)_legacyHandleViewDidLayoutSubviews +{ + // In modal presentation the view does not automatic resize in iOS7 and iOS8. As workaround we adjust the frame of the + // view manually + if (self.presentingViewController != nil) { + CGSize maxConstrainedSize = [self nodeConstrainedSize].max; + _node.frame = (CGRect){.origin = CGPointZero, .size = maxConstrainedSize}; + } } - (void)viewDidLayoutSubviews @@ -177,7 +191,19 @@ ASVisibilityDepthImplementation; - (ASSizeRange)nodeConstrainedSize { - CGSize viewSize = self.view.bounds.size; + if (AS_AT_LEAST_IOS9) { + CGSize viewSize = self.view.bounds.size; + return ASSizeRangeMake(viewSize, viewSize); + } else { + return [self _legacyConstrainedSize]; + } +} + +- (ASSizeRange)_legacyConstrainedSize +{ + // In modal presentation the view does not have the right bounds in iOS7 and iOS8. As workaround using the superviews + // view bounds + CGSize viewSize = (self.presentingViewController != nil) ? self.view.superview.bounds.size : self.view.bounds.size; return ASSizeRangeMake(viewSize, viewSize); }