我试图在我的应用程序启动时检测设备是否是 iPhone 5。如果设备是 iPhone,我想启动我的故事板,否则另一个故事板。我在 didFinishLaunchingWithOptions 方法中尝试了这段代码:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
UIStoryboard *storyBoard;
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 1136){
storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone_5" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
}
}
它似乎工作但当应用程序启动时只有一个黑屏。我认为情节提要有问题(每个情节提要作为 2 个具有 2 个视图的视图控制器)。我有两个视图之一作为“初始视图控制器”,但总是有没有正确视图的背景屏幕。
有人遇到过这个问题吗?