Handle error when splash image is missing.

From pull request:
https://github.com/apache/cordova-plugin-splashscreen/pull/1
This commit is contained in:
Nathan Peles 2013-12-06 14:38:01 -05:00 committed by Andrew Grieve
parent 9541c1eb37
commit d799eda020

View File

@ -163,7 +163,7 @@
- (void)updateBounds - (void)updateBounds
{ {
UIImage* img = _imageView.image; UIImage* img = _imageView.image;
CGRect imgBounds = CGRectMake(0, 0, img.size.width, img.size.height); CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero;
CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size; CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size;
@ -172,8 +172,8 @@
CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil]; CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil];
if (!(IsAtLeastiOSVersion(@"7.0"))) { if (!(IsAtLeastiOSVersion(@"7.0"))) {
imgBounds.origin.y -= statusFrame.size.height; imgBounds.origin.y -= statusFrame.size.height;
} }
} else { } else if (imgBounds.size.width > 0) {
CGRect viewBounds = self.viewController.view.bounds; CGRect viewBounds = self.viewController.view.bounds;
CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height; CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height;
CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height; CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height;