Skip to content
Permalink
Browse files
CB-9043 Fix the ios splashscreen being deformed on orientation change
  • Loading branch information
daserge committed Dec 22, 2015
1 parent ccb3c2f commit 875ccbf5bcacc10918f712d6b3455694381b2a2e
Showing 1 changed file with 38 additions and 1 deletion.
@@ -244,10 +244,47 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
return imageName;
}

- (UIInterfaceOrientation)getCurrentOrientation
{
UIInterfaceOrientation iOrientation = [UIApplication sharedApplication].statusBarOrientation;
UIDeviceOrientation dOrientation = [UIDevice currentDevice].orientation;

bool landscape;

if (dOrientation == UIDeviceOrientationUnknown || dOrientation == UIDeviceOrientationFaceUp || dOrientation == UIDeviceOrientationFaceDown) {
// If the device is laying down, use the UIInterfaceOrientation based on the status bar.
landscape = UIInterfaceOrientationIsLandscape(iOrientation);
} else {
// If the device is not laying down, use UIDeviceOrientation.
landscape = UIDeviceOrientationIsLandscape(dOrientation);

// There's a bug in iOS!!!! http://openradar.appspot.com/7216046
// So values needs to be reversed for landscape!
if (dOrientation == UIDeviceOrientationLandscapeLeft)
{
iOrientation = UIInterfaceOrientationLandscapeRight;
}
else if (dOrientation == UIDeviceOrientationLandscapeRight)
{
iOrientation = UIInterfaceOrientationLandscapeLeft;
}
else if (dOrientation == UIDeviceOrientationPortrait)
{
iOrientation = UIInterfaceOrientationPortrait;
}
else if (dOrientation == UIDeviceOrientationPortraitUpsideDown)
{
iOrientation = UIInterfaceOrientationPortraitUpsideDown;
}
}

return iOrientation;
}

// Sets the view's frame and image.
- (void)updateImage
{
NSString* imageName = [self getImageName:[[UIApplication sharedApplication] statusBarOrientation] delegate:(id<CDVScreenOrientationDelegate>)self.viewController device:[self getCurrentDevice]];
NSString* imageName = [self getImageName:[self getCurrentOrientation] delegate:(id<CDVScreenOrientationDelegate>)self.viewController device:[self getCurrentDevice]];

if (![imageName isEqualToString:_curImageName])
{

0 comments on commit 875ccbf

Please sign in to comment.