【问题标题】:performing segue from appdelegate从 appdelegate 执行 segue
【发布时间】:2013-01-06 11:22:51
【问题描述】:

我有以下代码:

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

并且用户没有被引导到那里。

怎么了?

【问题讨论】:

    标签: objective-c cocoa-touch uiwebview appdelegate


    【解决方案1】:

    rootViewController 当前未定义。您不能“从 App Delegate 执行转场”,转场是视图控制器之间的转换。您需要启动视图控制器而不是执行转场。

    self.window.rootViewController = baseViewController;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-22
      • 2012-08-31
      • 1970-01-01
      • 2019-07-31
      • 2017-12-06
      • 2018-11-08
      • 1970-01-01
      相关资源
      最近更新 更多