【问题标题】:Segue Presently from Appdelegate to UITabBarController in swift目前从 Appdelegate 快速转到 UITabBarController
【发布时间】:2016-08-26 06:43:40
【问题描述】:

我想从AppDelegate 转到UITabBarController 的第一视图。 我将UITabBarController 中的StoryBoardID 分配为“主页”。

我尝试了以下代码:

 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。 我现在想继续。

【问题讨论】:

标签: ios swift uitabbarcontroller segue appdelegate


【解决方案1】:

您需要设置viewControllers 而不是pushViewController

rootViewController.viewControllers = [viewController]

而不是

rootViewController.pushViewController(viewController, animated: true)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 1970-01-01
    • 2023-03-31
    • 2010-11-20
    • 2011-01-02
    相关资源
    最近更新 更多