我想针对 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 英寸屏幕。(我包括三个启动图像(Default-667h@2x.png,Default-736@3x.png,Default-568@2x .png) 也。
我必须做些什么来解决这个问题。
我检查了其他与我类似的问题,并使用了他们的代码,但所有这些都不起作用。那可能是我的技术水平比较排。