0

好吧,我徹底改變了我以前的代碼,這是我需要的,但最後推導航控制器不工作推到navigationController不起作用

 if application.applicationState == UIApplicationState.Background || application.applicationState == UIApplicationState.Inactive { 
     if let user = userInfo["user"] as? String{ 
      User.loadUserById(user, completion: {result in 
       let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController as! SWRevealViewController 
       let StoryB = UIStoryboard(name: "Main", bundle: nil) 
       let Logged : UITabBarController = StoryB.instantiateViewControllerWithIdentifier("TabBarController") as! UITabBarController 
       rootViewController.setFrontViewPosition(FrontViewPosition.Left, animated: true) 
       let profileViewController : UserProfileVC = StoryB.instantiateViewControllerWithIdentifier("UserProfileVC") as! UserProfileVC 
       profileViewController.user = result 
       rootViewController.pushFrontViewController(Logged, animated: true) 
       let wc = rootViewController.frontViewController as! UITabBarController 
       if let wcc = wc.selectedViewController as? UINavigationController{ 
        wcc.pushViewController(profileViewController, animated: true) 
       } 

      }) 

     } 

    } 
+0

你確定「TabBarController」是你的TabBarController的正確標識符嗎? – AnthonyR

+0

我已經將它設置爲StoryBoardID,但我認爲TabBarController不正確控制器我想呈現。前段時間我編輯了我的問題,對不起,但我不能發佈更好的圖片,謝謝 –

+0

什麼是崩潰的線?我的屏幕截圖上看不到任何內容。你想顯示什麼viewController? – AnthonyR

回答

0

這是不對的,我是推新的tabbarcontroller爲根,這段代碼工作

 if application.applicationState == UIApplicationState.Background || application.applicationState == UIApplicationState.Inactive { 
     if let type = userInfo["type"] as? String{ 
      if type == "wink" || type == "met" { 
       if let user = userInfo["user"] as? String{ 
        User.loadUserById(user, completion: {result in 
         if let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController as? SWRevealViewController{ 

          let StoryB = UIStoryboard(name: "Main", bundle: nil) 
          rootViewController.setFrontViewPosition(FrontViewPosition.Left, animated: true) 
          let profileViewController : UserProfileVC = StoryB.instantiateViewControllerWithIdentifier("UserProfileVC") as! UserProfileVC 
          profileViewController.user = result 
          if let tabBar = rootViewController.frontViewController as? UITabBarController{ 
           if let navigationController = tabBar.selectedViewController as? UINavigationController{ 
            navigationController.pushViewController(profileViewController, animated: true) 
           } 
          } 

         } 

        }) 

       } 
      } 
     } 

    }