如何从AppDelegate打开特定的选项卡视图

时间:2016-08-27 12:24:06

标签: swift appdelegate tabbarcontroller

我的根视图是标签栏控制器,我想在收到特定通知时在特定标签上打开应用程序。如果我使用presentViewController,标签栏会消失。有没有具体的方法来做到这一点?

1 个答案:

答案 0 :(得分:8)

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let myTabBar = self.window.rootViewController as! UITabBarController // Getting Tab Bar
    myTabBar.selectedIndex = 2 //Selecting tab here
    return true
}