platform/iphone/Classes/SplashViewController.m in rhodes-3.5.1.12 vs platform/iphone/Classes/SplashViewController.m in rhodes-5.5.0

- old
+ new

@@ -80,47 +80,70 @@ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; int scrnWidth = 0; int scrnHeight = 0; + + int app_width = 0; + int app_height = 0; - if ((orientation == UIInterfaceOrientationPortrait) || (orientation == UIInterfaceOrientationPortraitUpsideDown)) { - scrnWidth = (int)(srcrnBounds.size.width*scales+0.5); - scrnHeight = (int)(srcrnBounds.size.height*scales+0.5); - } - else { - scrnWidth = (int)(srcrnBounds.size.height*scales+0.5); - scrnHeight = (int)(srcrnBounds.size.width*scales+0.5); - } + + scrnWidth = (int)(srcrnBounds.size.width*scales+0.5); + scrnHeight = (int)(srcrnBounds.size.height*scales+0.5); + app_width = (int)(appFrame.size.width+0.5); + app_height = (int)(appFrame.size.height+0.5); + - if ((image_width != scrnWidth) || (image_height != scrnHeight) || (img_scale != scales)) + if ((image_width != scrnWidth) || (image_height != scrnHeight) || (img_scale != scales)) { - // scale to app frame - self.frame = appFrame; - CGRect rect; - - rect.origin.x = appFrame.origin.x; - rect.origin.y = appFrame.origin.y; - - float width_k = (appFrame.size.width * scales) / (float)image_width; - float height_k = (appFrame.size.height * scales) / (float)image_height; + if ((((int)[img size].width) != app_width) || (((int)[img size].height) != app_height)) { + // scale to app frame + self.frame = srcrnBounds;//appFrame; + CGRect rect; + + rect.origin.x = 0;//appFrame.origin.x; + rect.origin.y = 0;//appFrame.origin.y; - if (width_k >= height_k) { - rect.size.width = appFrame.size.width; - rect.size.height = (((float)image_height) / scales) * width_k; + float res_w = 0; + float res_h = 0; + + float width_k = (app_width * scales) / (float)image_width; + float height_k = (app_height * scales) / (float)image_height; + + if (width_k >= height_k) { + res_w = app_width; + res_h = (((float)image_height) / scales) * width_k; + } + else { + res_h = app_height; + res_w = (((float)image_width) / scales) * height_k; + } + + //if ((orientation == UIInterfaceOrientationPortrait) || (orientation == UIInterfaceOrientationPortraitUpsideDown)) { + if (orientation == UIInterfaceOrientationPortraitUpsideDown) { + rect.origin.x -= (res_w - app_width); + } + rect.size.width = res_w; + rect.size.height = res_h; + //} + //else { + // if (orientation == UIInterfaceOrientationLandscapeLeft) { + // //rect.origin.x -= (res_h - app_height); + // } + // else { + // rect.origin.x -= (res_h - app_height); + // } + // rect.size.width = res_h; + // rect.size.height = res_w; + //} + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + self.frame = rect; + } } - else { - rect.size.height = appFrame.size.height; - rect.size.width = (((float)image_width) / scales) * height_k; - } - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - self.frame = rect; - } - } else { self.frame = srcrnBounds; } } @@ -194,10 +217,12 @@ NSString *pngDefaultPortraitUpsideDownPath = [NSString stringWithFormat:@"%@/Default-PortraitUpsideDown.png", resourcePath]; NSString *pngDefaultLandscapePath = [NSString stringWithFormat:@"%@/Default-Landscape.png", resourcePath]; NSString *pngDefaultLandscapeLeftPath = [NSString stringWithFormat:@"%@/Default-LandscapeLeft.png", resourcePath]; NSString *pngDefaultLandscapeRightPath = [NSString stringWithFormat:@"%@/Default-LandscapeRight.png", resourcePath]; NSString *pngDefaultiPhone5 = [NSString stringWithFormat:@"%@/Default-568h@2x.png", resourcePath]; + NSString *pngDefaultiPhone6 = [NSString stringWithFormat:@"%@/Default-667h@2x.png", resourcePath]; + NSString *pngDefaultiPhone6plus = [NSString stringWithFormat:@"%@/Default-736h@3x.png", resourcePath]; CGRect win_frame = [[[UIApplication sharedApplication] keyWindow] bounds]; CGRect frame = myframe; float scales = 1;//[[UIScreen mainScreen] scale]; @@ -261,22 +286,43 @@ if (is_HiResolution) { if ([fileManager fileExistsAtPath:pngDefault2xPath]) { result = pngDefault2xPath; } // check for iPhone5 screen - if (frame.size.height*scales > 1000) { - result = pngDefaultiPhone5; + if (frame.size.height*scales >= (1136-1)) { + if ([fileManager fileExistsAtPath:pngDefaultiPhone5]) { + result = pngDefaultiPhone5; + } } + if (frame.size.height*scales >= (1334-1)) { + if ([fileManager fileExistsAtPath:pngDefaultiPhone6]) { + result = pngDefaultiPhone6; + } + } + if (frame.size.height*scales >= (2208-1)) { + if ([fileManager fileExistsAtPath:pngDefaultiPhone6plus]) { + result = pngDefaultiPhone6plus; + } + } } } if (result == nil) { if ([fileManager fileExistsAtPath:pngDefaultPath]) { result = pngDefaultPath; } else if ([fileManager fileExistsAtPath:pngDefault2xPath]) { result = pngDefault2xPath; } + else if ([fileManager fileExistsAtPath:pngDefaultiPhone5]) { + result = pngDefaultiPhone5; + } + else if ([fileManager fileExistsAtPath:pngDefaultiPhone6]) { + result = pngDefaultiPhone6; + } + else if ([fileManager fileExistsAtPath:pngDefaultiPhone6plus]) { + result = pngDefaultiPhone6plus; + } else if ([fileManager fileExistsAtPath:pngDefaultPortraitPath]) { result = pngDefaultPortraitPath; } else if ([fileManager fileExistsAtPath:pngDefaultLandscapePath]) { result = pngDefaultLandscapePath; @@ -306,27 +352,32 @@ NSString *pngDefaultPortraitUpsideDownPath = [NSString stringWithFormat:@"%@/Default-PortraitUpsideDown.png", resourcePath]; NSString *pngDefaultLandscapePath = [NSString stringWithFormat:@"%@/Default-Landscape.png", resourcePath]; NSString *pngDefaultLandscapeLeftPath = [NSString stringWithFormat:@"%@/Default-LandscapeLeft.png", resourcePath]; NSString *pngDefaultLandscapeRightPath = [NSString stringWithFormat:@"%@/Default-LandscapeRight.png", resourcePath]; NSString *pngDefaultiPhone5 = [NSString stringWithFormat:@"%@/Default-568h@2x.png", resourcePath]; + NSString *pngDefaultiPhone6 = [NSString stringWithFormat:@"%@/Default-667@2x.png", resourcePath]; + NSString *pngDefaultiPhone6plus = [NSString stringWithFormat:@"%@/Default-736h@3x.png", resourcePath]; return ( //([fileManager fileExistsAtPath:pngLoadingPath]) || ([fileManager fileExistsAtPath:pngDefaultPath]) || ([fileManager fileExistsAtPath:pngDefault2xPath]) || ([fileManager fileExistsAtPath:pngDefaultPortraitPath]) || ([fileManager fileExistsAtPath:pngDefaultPortraitUpsideDownPath]) || ([fileManager fileExistsAtPath:pngDefaultLandscapeLeftPath]) || ([fileManager fileExistsAtPath:pngDefaultLandscapeRightPath]) || ([fileManager fileExistsAtPath:pngDefaultiPhone5]) || + ([fileManager fileExistsAtPath:pngDefaultiPhone6]) || + ([fileManager fileExistsAtPath:pngDefaultiPhone6plus]) || ([fileManager fileExistsAtPath:pngDefaultLandscapePath]) ); } -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ BOOL is_iPad = NO; NSString *model = [[UIDevice currentDevice] model]; // "iPad ..." if ([model hasPrefix:@"iPad"]) { is_iPad = YES; @@ -334,8 +385,30 @@ if (!is_iPad) { return NO; } return YES; } + +#ifdef __IPHONE_6_0 +- (BOOL)shouldAutorotate +{ + BOOL is_iPad = NO; + + NSString *model = [[UIDevice currentDevice] model]; // "iPad ..." + if ([model hasPrefix:@"iPad"]) { + is_iPad = YES; + } + if (!is_iPad) { + return NO; + } + return YES; +} + + +- (NSUInteger)supportedInterfaceOrientations +{ + return UIInterfaceOrientationMaskAll; +} +#endif @end