swift 目前从 Appdelegate 转至 UITabBarController

Segue Presently from Appdelegate to UITabBarController in swift

我想从 AppDelegate 转到 UITabBarController 的第一个视图。 我将 UITabBarController 中的 StoryBoardID 分配为 "HomePage"。

我尝试了以下代码:

 let storyboard = UIStoryboard(name: "Main", bundle: nil)
 let viewController: UITabBarController = storyboard.instantiateViewControllerWithIdentifier("HomePage") as! UITabBarController

 let rootViewController = self.window!.rootViewController as! UINavigationController
 rootViewController.pushViewController(viewController, animated: true)

它有效,但我在我不想要的目标视图上给出了 BackBarButton。 我现在想继续。

您需要设置 viewControllers 而不是 pushViewController

rootViewController.viewControllers = [viewController]

而不是

rootViewController.pushViewController(viewController, animated: true)