iPhone 6 / iPhone 6+ launch screen size issue

419 Views Asked by At

I want to optimize my app for iPhone 6 and iPhone 6+

But I have a launch screen size problem.

I created a simple project, and AppDelegate's code is:

#import "AppDelegate.h"
#import "ViewControllerOne.h" //xib screen size is 4 inch.
#import "ViewControllerTwo.h" // xib screen size is 4.7 inch.
#import "ViewControllerThree.h" // xib screen size is 5.5 inch.


@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {


        if ([UIScreen mainScreen].bounds.size.height == 568.0) {//4 inch

            ViewControllerOne *first = [[ViewControllerOne alloc]init];
            UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:first];
            self.window.rootViewController = navigation;


        }

        else if ([UIScreen mainScreen].bounds.size.height == 667.0){//4.7inch

            ViewControllerTwo * second = [[ViewControllerTwo alloc]init];
            UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:second];
            self.window.rootViewController = navigation;

        }


        else if ([UIScreen mainScreen].bounds.size.height == 736.0){//5.5inch

            ViewControllerThree *third = [[ViewControllerThree alloc]init];
            UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:third];
            self.window.rootViewController = navigation;

        }


    }


    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];


    return YES;
}

@end

When I run iPhone 6 or iPhone 6+ simulator, it always appears 4inch screen when I run this project.(I included three launch image([email protected], [email protected], [email protected]) also.

What I have to do to resolve this problem.

I checked others question that similar to mine, and used their code, but all of those not works. That is maybe my technical skills relatively row.

2

There are 2 best solutions below

0
On

Once you specify the images in Assets Catalog you will see the right images

Go to YourAppTarget> General> App Icons and Launch Images> Launch Image Source > Use asset Catalog

and then drag the appropriate size for each device.

1
On

In addition to adding images you can also add a Launch Screen File. This is a .XIB file that allows you to specify constraints in addition of launch images. It only works on iOS8. To support iPhone 6 and 6+, we only add this file and specify constraints:

To set the Launch Screen File add it to your project:

File > New > User Interface > Launch Screen

Then go to: YourAppTarget > General > App Icons and Launch Image s> Launch Screen File > Set your newly created image

You will still need launch images for Retina 4" and 3.5", if you are supporting iOS 7.