简体   繁体   English

iPhone 6 / iPhone 6+启动屏幕尺寸问题

[英]iPhone 6 / iPhone 6+ launch screen size issue

I want to optimize my app for iPhone 6 and iPhone 6+ 我想针对iPhone 6和iPhone 6+优化我的应用

But I have a launch screen size problem. 但是我有一个启动屏幕大小的问题。

I created a simple project, and AppDelegate's code is: 我创建了一个简单的项目,AppDelegate的代码为:

#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(Default-667h@2x.png, Default-736@3x.png, Default-568@2x.png) also. 当我运行iPhone 6或iPhone 6+模拟器时,运行此项目时它始终显示4英寸屏幕。(我包括了三个启动图像(Default-667h @ 2x.png,Default-736 @ 3x.png,Default-568 @ 2x .png)。

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. 那也许是我的技术能力相对较差。

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 转到YourAppTarget>常规>应用程序图标和启动图像>启动图像源>使用资产目录

and then drag the appropriate size for each device. 然后为每个设备拖动适当的大小。

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. 这是一个.XIB文件,可让您指定启动映像之外的约束。 It only works on iOS8 . 它仅适用于iOS8 To support iPhone 6 and 6+, we only add this file and specify constraints: 为了支持iPhone 6和6+,我们仅添加此文件并指定约束:

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 然后转到: YourAppTarget>常规>应用程序图标和启动图像s>启动屏幕文件>设置新创建的图像

You will still need launch images for Retina 4" and 3.5", if you are supporting iOS 7. 如果您支持iOS 7,则仍需要Retina 4“和3.5”的启动图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM