From 8070c69e91c2e317baf3b970350f3c950ffcbfa3 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 28 Aug 2016 16:01:54 -0400 Subject: [PATCH 1/3] CB:-9161 Support iPad multitasking in iOS 9. (statusbar plugin side fix) --- src/ios/CDVStatusBar.m | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index ba4c04e0..0389851b 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -132,13 +132,15 @@ - (void)pluginInitialize // blank scroll view to intercept status bar taps self.webView.scrollView.scrollsToTop = NO; - UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds]; + + CGRect bounds = [self.viewController.view.window bounds]; + UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:bounds]; fakeScrollView.delegate = self; fakeScrollView.scrollsToTop = YES; [self.viewController.view addSubview:fakeScrollView]; // Add scrollview to the view heirarchy so that it will begin accepting status bar taps [self.viewController.view sendSubviewToBack:fakeScrollView]; // Send it to the very back of the view heirarchy - fakeScrollView.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height * 2.0f); // Make the scroll view longer than the screen itself - fakeScrollView.contentOffset = CGPointMake(0.0f, UIScreen.mainScreen.bounds.size.height); // Scroll down so a tap will take scroll view back to the top + fakeScrollView.contentSize = CGSizeMake(bounds.size.width, bounds.size.height * 2.0f); // Make the scroll view longer than the screen itself + fakeScrollView.contentOffset = CGPointMake(0.0f, bounds.size.height); // Scroll down so a tap will take scroll view back to the top } - (void)onReset { @@ -182,7 +184,7 @@ - (void) initializeStatusBarBackgroundView CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; if ([[UIApplication sharedApplication]statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown && - statusBarFrame.size.height + statusBarFrame.origin.y == [[UIScreen mainScreen] bounds].size.height) { + statusBarFrame.size.height + statusBarFrame.origin.y == [self.viewController.view.window bounds].size.height) { // When started in upside-down orientation on iOS 7, status bar will be bound to lower edge of the // screen (statusBarFrame.origin.y will be somewhere around screen height). In this case we need to @@ -200,8 +202,8 @@ - (void) initializeStatusBarBackgroundView - (CGRect) invertFrameIfNeeded:(CGRect)rect { // landscape is where (width > height). On iOS < 8, we need to invert since frames are - // always in Portrait context - if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) && (rect.size.width < rect.size.height)) { + // always in Portrait context. Do not run this on ios 8 or above to avoid breaking ipad pro multitask layout + if (!IsAtLeastiOSVersion(@"8.0") && UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) && (rect.size.width < rect.size.height)) { CGFloat temp = rect.size.width; rect.size.width = rect.size.height; rect.size.height = temp; @@ -440,8 +442,8 @@ -(void)resizeWebView BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0")); if (isIOS7) { - CGRect bounds = [[UIScreen mainScreen] bounds]; - bounds = [self invertFrameIfNeeded:bounds]; + CGRect bounds = [self.viewController.view.window bounds]; + bounds = [self invertFrameIfNeeded:bounds]; if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) { self.viewController.view.frame = bounds; @@ -472,7 +474,7 @@ -(void)resizeWebView self.webView.frame = frame; } } else { - CGRect bounds = [[UIScreen mainScreen] applicationFrame]; + CGRect bounds = [self.viewController.view.window bounds]; self.viewController.view.frame = bounds; } } From 21ef1637623c2b2524ce58ada55733c5031bcf9c Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 28 Aug 2016 16:01:54 -0400 Subject: [PATCH 2/3] CB-10288 statusbar plugin interaction with iOS multitasking --- src/ios/CDVStatusBar.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index 0389851b..112023c9 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -203,7 +203,7 @@ - (void) initializeStatusBarBackgroundView - (CGRect) invertFrameIfNeeded:(CGRect)rect { // landscape is where (width > height). On iOS < 8, we need to invert since frames are // always in Portrait context. Do not run this on ios 8 or above to avoid breaking ipad pro multitask layout - if (!IsAtLeastiOSVersion(@"8.0") && UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) && (rect.size.width < rect.size.height)) { + if (!IsAtLeastiOSVersion(@"8.0") && UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { CGFloat temp = rect.size.width; rect.size.width = rect.size.height; rect.size.height = temp; @@ -442,8 +442,8 @@ -(void)resizeWebView BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0")); if (isIOS7) { - CGRect bounds = [self.viewController.view.window bounds]; - bounds = [self invertFrameIfNeeded:bounds]; + CGRect bounds = [self.viewController.view.window bounds]; + bounds = [self invertFrameIfNeeded:bounds]; if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) { self.viewController.view.frame = bounds; @@ -474,7 +474,7 @@ -(void)resizeWebView self.webView.frame = frame; } } else { - CGRect bounds = [self.viewController.view.window bounds]; + CGRect bounds = [[UIScreen mainScreen] applicationFrame]; self.viewController.view.frame = bounds; } } From cc5ec71c99251132b06e4cc46716b4183c881ba1 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Thu, 1 Sep 2016 10:45:42 -0400 Subject: [PATCH 3/3] CB-10288 statusbar plugin interaction with iOS multitasking (update) --- src/ios/CDVStatusBar.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index 112023c9..44906126 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -132,15 +132,13 @@ - (void)pluginInitialize // blank scroll view to intercept status bar taps self.webView.scrollView.scrollsToTop = NO; - - CGRect bounds = [self.viewController.view.window bounds]; - UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:bounds]; + UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds]; fakeScrollView.delegate = self; fakeScrollView.scrollsToTop = YES; [self.viewController.view addSubview:fakeScrollView]; // Add scrollview to the view heirarchy so that it will begin accepting status bar taps [self.viewController.view sendSubviewToBack:fakeScrollView]; // Send it to the very back of the view heirarchy - fakeScrollView.contentSize = CGSizeMake(bounds.size.width, bounds.size.height * 2.0f); // Make the scroll view longer than the screen itself - fakeScrollView.contentOffset = CGPointMake(0.0f, bounds.size.height); // Scroll down so a tap will take scroll view back to the top + fakeScrollView.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height * 2.0f); // Make the scroll view longer than the screen itself + fakeScrollView.contentOffset = CGPointMake(0.0f, UIScreen.mainScreen.bounds.size.height); // Scroll down so a tap will take scroll view back to the top } - (void)onReset {