ios - swift 从 Appdelegate 转至 UITabBarController

标签 ios swift uitabbarcontroller segue appdelegate

我想从 AppDelegate 转到 UITabBarController 的第一个 View 。 我将 UITabBarControllerStoryBoardID 指定为“主页”。

我试过下面的代码:

 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)

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

最佳答案

您需要设置您的 viewControllers 而不是 pushViewController

rootViewController.viewControllers = [viewController]

代替

rootViewController.pushViewController(viewController, animated: true)

关于ios - swift 从 Appdelegate 转至 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39159892/

相关文章:

ios - SpriteKit 加载新场景但 Sprite 立即掉落

ios - 当我从另一个 View 返回 View 时 TabBarController 消失

ios - 使用 presentViewController :animated:completion: in iOS 8 时 presentingViewController 为 nil

ios - 每次单击按钮后,如何在 UILabel 上逐一显示文本?

ios - 使用 Swift/SwiftyJSON 将嵌套的 JSON 解析为字典

ios - X代码 7.3.1, "Undefined symbols for architecture arm64"

iPhone - 带有标签栏 Controller 的应用程序 - 在顶部显示间隙

iphone - UIViewController 中的 UINavigationController

ios - IOS 中的 MDM 究竟是如何工作的?

ios - 为什么我的 subview 没有显示在堆栈顶部?