Objective c 从appdelegate执行segue

Objective c 从appdelegate执行segue,objective-c,cocoa-touch,uiwebview,appdelegate,Objective C,Cocoa Touch,Uiwebview,Appdelegate,我有以下代码: - (void)applicationDidBecomeActive:(UIApplication *)application { //make sure that the user credentials are still ok if (userLeftApplication){ BaseViewController * baseViewController = [[BaseViewController alloc]init];

我有以下代码:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    //make sure that the user credentials are still ok
    if (userLeftApplication){
        BaseViewController * baseViewController = [[BaseViewController alloc]init];
        BOOL detailsAreOK = [baseViewController credentialsValidated];
        if (!detailsAreOK){
            [self.window.rootViewController performSegueWithIdentifier: @"fromSplashToLogin" sender: self.window.rootViewController];
        }
        userLeftApplication = FALSE;
    }
}
但是,我在尝试执行segue时遇到以下异常:

Attempt to present <LoginViewController: 0x2012e180> on <FirstViewController: 0x1f59cef0> whose view is not in the window hierarchy!
尝试显示不在窗口层次结构中的视图!
用户没有被引导到那里


怎么了?

当前未定义rootViewController。不能“从应用程序代理执行分段”,分段是视图控制器之间的过渡。您需要启动视图控制器,而不是执行segue

self.window.rootViewController = baseViewController;