You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by jc...@apache.org on 2016/07/21 19:40:07 UTC
cordova-plugin-splashscreen git commit: Fix crash on iOS when
reloading page from remote Safari
Repository: cordova-plugin-splashscreen
Updated Branches:
refs/heads/master d65c0c7cc -> 0a8b5be3d
Fix crash on iOS when reloading page from remote Safari
This closes #110
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/commit/0a8b5be3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/tree/0a8b5be3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/diff/0a8b5be3
Branch: refs/heads/master
Commit: 0a8b5be3d1f78ef699c5ed6db1b964649fe7f582
Parents: d65c0c7
Author: Franco Bugnano <fr...@bugnano.it>
Authored: Thu Jul 21 17:14:42 2016 +0200
Committer: Julio C�sar <jc...@gmail.com>
Committed: Thu Jul 21 21:39:41 2016 +0200
----------------------------------------------------------------------
src/ios/CDVSplashScreen.m | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/0a8b5be3/src/ios/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSplashScreen.m b/src/ios/CDVSplashScreen.m
index 448a23f..8ad8116 100644
--- a/src/ios/CDVSplashScreen.m
+++ b/src/ios/CDVSplashScreen.m
@@ -77,7 +77,7 @@
BOOL autorotateValue = (device.iPad || device.iPhone6Plus) ?
[(CDVViewController *)self.viewController shouldAutorotateDefaultValue] :
NO;
-
+
[(CDVViewController *)self.viewController setEnabledAutorotation:autorotateValue];
NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:[@"TopActivityIndicator" lowercaseString]];
@@ -142,20 +142,28 @@
_curImageName = nil;
self.viewController.view.userInteractionEnabled = YES; // re-enable user interaction upon completion
- [self.viewController.view removeObserver:self forKeyPath:@"frame"];
- [self.viewController.view removeObserver:self forKeyPath:@"bounds"];
+ @try {
+ [self.viewController.view removeObserver:self forKeyPath:@"frame"];
+ [self.viewController.view removeObserver:self forKeyPath:@"bounds"];
+ }
+ @catch (NSException *exception) {
+ // When reloading the page from a remotely connected Safari, there
+ // are no observers, so the removeObserver method throws an exception,
+ // that we can safely ignore.
+ // Alternatively we can check whether there are observers before calling removeObserver
+ }
}
- (CDV_iOSDevice) getCurrentDevice
{
CDV_iOSDevice device;
-
+
UIScreen* mainScreen = [UIScreen mainScreen];
CGFloat mainScreenHeight = mainScreen.bounds.size.height;
CGFloat mainScreenWidth = mainScreen.bounds.size.width;
-
+
int limit = MAX(mainScreenHeight,mainScreenWidth);
-
+
device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
device.retina = ([mainScreen scale] == 2.0);
@@ -166,7 +174,7 @@
// this is appropriate for detecting the runtime screen environment
device.iPhone6 = (device.iPhone && limit == 667.0);
device.iPhone6Plus = (device.iPhone && limit == 736.0);
-
+
return device;
}
@@ -174,15 +182,15 @@
{
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
-
+
NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
-
+
// Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape
BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape);
BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);
// this means there are no mixed orientations in there
BOOL isOrientationLocked = !(supportsPortrait && supportsLandscape);
-
+
if (imageName)
{
imageName = [imageName stringByDeletingPathExtension];
@@ -251,7 +259,7 @@
case UIInterfaceOrientationLandscapeRight:
imageName = [imageName stringByAppendingString:@"-Landscape"];
break;
-
+
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
default:
@@ -260,7 +268,7 @@
}
}
}
-
+
return imageName;
}
@@ -457,7 +465,7 @@
[weakSelf hideViews];
}
completion:^(BOOL finished) {
- // Always destroy views, otherwise you could have an
+ // Always destroy views, otherwise you could have an
// invisible splashscreen that is overlayed over your active views
// which causes that no touch events are passed
if (!_destroyed) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org