我决定为 ios6 和 ios7 使用不同的故事板,所以我需要在代码中实例化故事板。我在应用程序委托中有这个方法- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
但什么也没发生,它总是实例化在iPadStoryboard
iPad 模拟器上运行时命名的故事板,我已经从 info.plist 中删除了主界面。知道这里发生了什么吗?
- (void)loadStoryboards
{
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
UIStoryboard *mainStoryboard = nil;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
NSLog(@"1");
if (iOSDeviceScreenSize.height == 480)
{
mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone-ios5" bundle:nil];
} else {
NSLog(@"loading iPad storyboard");
mainStoryboard = [UIStoryboard storyboardWithName:@"iPadStoryboardOS6" bundle:nil];
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
NSLog(@"2");
if (iOSDeviceScreenSize.height == 480)
{
mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
} else {
mainStoryboard = [UIStoryboard storyboardWithName:@"iPadStoryboard" bundle:nil];
}
self.initialViewController = [mainStoryboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.initialViewController;
[self.window makeKeyAndVisible];
}