Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 加载不同的情节提要导致错误_Ios_Objective C_Uistoryboard_Appdelegate - Fatal编程技术网

Ios 加载不同的情节提要导致错误

Ios 加载不同的情节提要导致错误,ios,objective-c,uistoryboard,appdelegate,Ios,Objective C,Uistoryboard,Appdelegate,我正在尝试加载不同的故事板,但遇到此错误。应用程序启动结束时,windows应具有根视图控制器。有人能帮我吗 - (UIStoryboard *)grabStoryboard { UIStoryboard *storyboard; // detect the height of our screen int height = [UIScreen mainScreen].bounds.size.height; if (height == 480) {

我正在尝试加载不同的故事板,但遇到此错误。应用程序启动结束时,windows应具有根视图控制器。有人能帮我吗

- (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;
}

出现此错误是因为编译器看到函数可以返回未初始化的序列图像板变量的情况。如果if语句中的non-of为true,则可能会发生这种情况。因此,最好重写此函数,使其始终返回初始化的情节提要变量。我的建议是改变确定设备型号的方式。请看下面的提示。

我认为您的一个或多个故事板没有入口点,请确保全部验证。您可以在此处查看官方文档

错误几乎肯定存在于appdelegate中的ApplicationIDFinishLaunching函数中。在这篇文章和旁注中,你真的不应该为每个iPhone屏幕大小加载不同的故事板。自动布局和大小类可以以一种更加优雅和易于管理的方式处理这些问题。。。