Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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_Controller_Launch_Appdelegate - Fatal编程技术网

页面视图控制器首次启动ios

页面视图控制器首次启动ios,ios,controller,launch,appdelegate,Ios,Controller,Launch,Appdelegate,我有个问题。 我创建了一个页面视图控制器来显示我的应用程序的教程。此页面视图控制器在运行期间显示 应用程序的首次启动。我正在向AppDelegate.m文件添加以下代码 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([[NSUserDefaults standardUserDefaults] boolF

我有个问题。 我创建了一个页面视图控制器来显示我的应用程序的教程。此页面视图控制器在运行期间显示 应用程序的首次启动。我正在向AppDelegate.m文件添加以下代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
    {
        //Normal flow
    }
    else
    {
        //To show the tutorial
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
        [[NSUserDefaults standardUserDefaults] synchronize];

        TutorialViewController* tutorialViewController = [[TutorialViewController alloc] init];
        [self.window setRootViewController:tutorialViewController];
    }
        return YES;
}
我的问题是,在应用程序的第一次午餐期间,我遇到了以下错误

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“*-[\u NSPlaceholderArray initWithObjects:计数:]:尝试从对象[0]插入nil对象” *第一次抛出调用堆栈:

有人能帮我解决这个问题吗


干杯。

谢谢你的建议。我的错误在PageViewController中。我将调用视图控制器的行替换为:

UIStoryboard*mainStoryboard=[UIStoryboard情节提要,名称:@Main bundle:nil]

ViewController=ViewController[mainStoryboard实例化viewcontrollerwhiteIdentifier:@firstViewController]

[self.window setRootViewController:controller]

它成功了:


问候

我想问题不在AppDelegate.m文件中。此错误表示您正在尝试初始化内部引用为nil的NSArray对象。请添加一个all exception断点,并在应用程序崩溃时通知我们该行。它在[self.window setRootViewController:tutorialViewController]行崩溃;