我最近将我的应用程序转换为通用二进制文件,并将现有的情节提要复制到 iPad 格式。我的印象是我可以有条件地从该方法加载情节提要文件,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
我在上述方法中有以下代码,但我的初始场景没有从情节提要文件中加载。我得到一个没有任何内容的白屏,但我确实看到了状态栏。
// iPad Legacy 1024 x 768
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
// the iOS device is in the iPad family.
NSLog(@"the iOS device = %@",[UIDevice currentDevice]);
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
NSLog(@"The size of screen is %f",iOSDeviceScreenSize.height);
if (iOSDeviceScreenSize.height == 1024) {
// load storyboard , load rootviewcontroller, show initial scene
UIStoryboard *sbipad = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
ViewControllerWelcome *vcwelcome = [sbipad instantiateInitialViewController];
self.window.rootViewController = vcwelcome;
[self.window makeKeyAndVisible];
NSLog(@"iPad storyboard file loaded");
}
}
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480) {
// iphone 3GS, 4, 4S, and iPod Touch 3rd and 4th gen 3.5 inch screen diagnolly measured
UIStoryboard *sbiphone = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
ViewControllerWelcome *vcwelcome = [sbiphone instantiateInitialViewController];
self.window.rootViewController = vcwelcome;
[self.window makeKeyAndVisible];
NSLog(@"iPhone storyboard file loaded");
}
if (iOSDeviceScreenSize.height == 568) {
// iphone 5 and ipod touch 5th gen: 4 inch screen diagnolly measured
UIStoryboard *sbiphone = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
ViewControllerWelcome *vcwelcome = [sbiphone instantiateInitialViewController];
self.window.rootViewController = vcwelcome;
[self.window makeKeyAndVisible];
NSLog(@"iPhone storyboard file loaded for iPhone 5 (4inch screen)");
}
}
return YES;