【发布时间】:2016-08-17 04:57:17
【问题描述】:
我正在尝试加载不同的故事板,但收到此错误应用程序窗口应该在应用程序启动结束时有一个根视图控制器。谁能帮帮我
- (UIStoryboard *)grabStoryboard {
UIStoryboard *storyboard;
// detect the height of our screen
int height = [UIScreen mainScreen].bounds.size.height;
if (height == 480) {
storyboard = [UIStoryboard storyboardWithName:@"iPhone_4" bundle:nil];
// NSLog(@"Device has a 3.5inch Display.");
}
if(height == 568)
{
storyboard = [UIStoryboard storyboardWithName:@"iPhone_5" bundle:nil];
// NSLog(@"Device has a 4inch Display.");
}
if(height == 667)
{
storyboard = [UIStoryboard storyboardWithName:@"iPhone_6" bundle:nil];
// NSLog(@"Device has a 4inch Display.");
}
if(height == 736)
{
storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// NSLog(@"Device has a 4inch Display.");
}
return storyboard;
}
【问题讨论】:
-
错误几乎肯定出在您的 appdelegate 中的 applicationdidfinishlaunching 函数中。也发一下
-
附带说明,您确实没有理由为每个 iPhone 屏幕尺寸加载不同的故事板。自动布局和大小类可以以更优雅、更易于管理的方式处理...
标签: ios objective-c uistoryboard appdelegate