2013-01-06 37 views
1

执行赛格瑞我有以下代码:从的appdelegate

- (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! 

和用户没有被定向那里。

出了什么问题?

回答

2

rootViewController目前未定义。你不能'从App Delegate执行segue',segues是视图控制器之间的转换。你需要启动视图控制器而不是执行一个segue。

self.window.rootViewController = baseViewController;