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

问题描述:

我想优化我的应用程序iPhone 6和iPhone 6+iPhone 6/iPhone 6+启动屏幕尺寸问题

但我有启动屏幕大小问题。

我创建了一个简单的项目,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 

当我运行iPhone 6或iPhone 6+模拟器,当我运行这个项目它总是出现4英寸屏幕(我包括三项启动图像([email protected][email protected][email protected])也。

我该怎么做才能解决这个问题。

我查别人质疑与我的类似,并使用他们的代码,但所有这些都不起作用,这可能是我的技术技能比较排。

+0

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LaunchImages.html – CSmith 2014-12-02 14:11:07

+1

您是否在项目的plist中声明了启动映像?或者当你点击项目文件时,项目“常规”选项卡? – Daniel 2014-12-02 14:32:57

+0

谢谢鲍勃和史密斯!我刚刚解决了这个问题。我没有在info.plist中声明我的启动图像。我宣布启动图像,一切都很好! – 2014-12-02 15:25:45

一旦您指定的资产类别的图像,你会看到右侧的图像

转到YourAppTarget>常规>应用程序图标和启动图像>启动图像源>使用资产类别

,然后拖动每个设备的适当尺寸。

+0

谢谢hariszaman,我会试试这个。 – 2014-12-02 16:25:17

除了添加图片,您还可以添加启动屏幕文件。这是一个.XIB文件,它允许您指定启动映像以外的约束。它只适用于iOS8。为了支持iPhone 6和6+,我们只添加此文件,并指定约束条件:

设置启动画面文件将其添加到您的项目:

文件>新建>用户界面>启动屏幕

然后去:YourAppTarget>常规>应用程序图标和启动图像S>启动画面文件>设置新创建的图像

你仍然需要推出图像视网膜4" 和3.5" ,如果你是增刊orting iOS 7.

+0

谢谢Legoless,这非常有帮助。 – 2014-12-03 05:57:56