从 AppDelegate 启动 ViewController,底部缺少标签栏

Launch ViewController from AppDelegate, tabbar missing from bottom

我正在开发我的第一个应用程序,我试图在我的应用程序中管理一个会话,我试图检查用户最近是否登录过。如果用户最近登录过,那么我想跳过登录页面,把他移到下一页。 这是我在做什么,但是我无法继续前进

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
       let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let viewControllerB = mainStoryboard.instantiateViewControllerWithIdentifier("account") as! AccountDetails
    let navController = UINavigationController(rootViewController: viewControllerB)
    let appDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
    appDelegate.window?.rootViewController = viewControllerB
    let vc = self.window?.rootViewController

    UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(navController, animated: true, completion: nil)
    return true
}

我能够到达所需的视图,但是该视图上的 Tabbar 丢失了。我想恢复原样。

第二个屏幕(我要显示的我的帐户)

 class AccountDetails: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
required init?(coder aDecoder: NSCoder) {
            super.init(coder: aDecoder)
            // Initialize Tab Bar Item
            tabBarItem = UITabBarItem(title: "Account Details", image: UIImage(named: "Account.png"), tag: 1)

        }

}

替换行self.window?.rootViewController?.presentViewController(navController, animated: true, completion: nil)

self.window?.rootViewController = navController

更改window的rootViewController:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    if(User loggin last time) {
        let yourTargetViewController = UIViewController()
        yourTargetViewController.view.backgroundColor = UIColor.redColor()
        self.window?.rootViewController = yourTargetViewController
    }
    return true
}

这是可行的解决方案

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let viewControllerB = mainStoryboard.instantiateViewControllerWithIdentifier("tabbar") as! UITabBarController
    let navController = UINavigationController(rootViewController: viewControllerB)
    let appDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
    appDelegate.window?.rootViewController = viewControllerB
    UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(navController, animated: true, completion: nil)

//tabbar是tabbarcontroller的storyboard ID