How to perform Segue in AppDelegate?

前端 未结 3 2417
广开言路
广开言路 2021-02-20 06:28

I am trying to complete an application on IOS 5.1 with Storyboard. Basically I am doing a dropbox app. Since I am using Dropbox SDK link to Dropbox is handled in AppDelegate.m.

3条回答
  •  轮回少年
    2021-02-20 07:03

    In my case i need to go to dashboard screen from appdelegate using segue, the code as below in objective c.

    if([rememberMe isEqualToString:@"YES"]){
            //Goto Dashboard
            self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            SWRevealViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"revealVc"];
            self.window.rootViewController = vc;
            [self.window.rootViewController performSegueWithIdentifier:@"sw_front" sender:self];
            [self.window makeKeyAndVisible];
        }else{
            //Goto login
            self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            LoginViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
            self.window.rootViewController = vc;
            [self.window makeKeyAndVisible];
        }
    

    Write inside your didFinishLaunchingWithOptions

    Hope it helps some one.

提交回复
热议问题