Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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 如何从AppDelegate调用视图控制器,即使用TabBarController时didFinishLaunchingWithOptions_Ios_Objective C_Iphone_Xcode - Fatal编程技术网

Ios 如何从AppDelegate调用视图控制器,即使用TabBarController时didFinishLaunchingWithOptions

Ios 如何从AppDelegate调用视图控制器,即使用TabBarController时didFinishLaunchingWithOptions,ios,objective-c,iphone,xcode,Ios,Objective C,Iphone,Xcode,我是iOS编程新手,对通过编程调用ViewController知之甚少。我正在为notes制作一个应用程序,我想让它有密码保护。我使用了TabBarController,其中一个选项卡用于设置(用于启用和禁用密码保护)。当应用程序启动时,我想知道,是启用了密码保护还是禁用了密码保护。如果启用,我想显示一个登录屏幕(即调用不同的视图控制器)。我认为我应该从AppDelegate中的didFinishLaunchingWithOptions方法中执行此操作,但我不知道如何执行。我尝试了一些方法,但失

我是iOS编程新手,对通过编程调用ViewController知之甚少。我正在为notes制作一个应用程序,我想让它有密码保护。我使用了TabBarController,其中一个选项卡用于设置(用于启用和禁用密码保护)。当应用程序启动时,我想知道,是启用了密码保护还是禁用了密码保护。如果启用,我想显示一个登录屏幕(即调用不同的视图控制器)。我认为我应该从AppDelegate中的didFinishLaunchingWithOptions方法中执行此操作,但我不知道如何执行。我尝试了一些方法,但失败了。请帮帮我


提前谢谢。

很抱歉投了反对票,我认为你不配。我在启动iOS时也遇到了同样的问题。这可能会有帮助

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

    //set NSDefaults when you set if password protection is needed - here you are checking to see if password enabling  exists

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    BOOL passwordExists;
    passwordExists = [defaults boolForKey:@"hasCompleted"];

    //jump to different view controller depending if BOOL is false or true
   //set names (ShowLogInScreenController) In StoryBoardID in the Interface Builder 
    UIStoryboard *storyBoard =[ UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UINavigationController *vc = [storyBoard instantiateViewControllerWithIdentifier:passwordExists ? @"ShowLogInScreenController" : @"PasswordProtectionDisabledViewController"];
    UINavigationController *questionsNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
    questionsNavigationController.navigationBar.hidden = YES;
    self.window.rootViewController = questionsNavigationController;
    return YES;
}

您能显示您尝试的代码吗?它工作正常,但问题是,现在我的选项卡栏不可见。