swif:
let tabBarController: UITabBarController = UIApplication.sharedApplication().keyWindow?.rootViewController as! UITabBarController
let nav: UINavigationController = tabBarController.selectedViewController as! UINavigationController
接下来就可以push出去
nav.pushViewController(vc, animated: true)
在你箱套太多层view情况下,或者xib情况下无法获取时,就可以使用,万能的
还可以这样子哦,获取你想要的tab
let tabBarController = UIApplication.sharedApplication().keyWindow?.rootViewController
let nav = tabBarController?.childViewControllers
let home:UINavigationController = nav![0] as! UINavigationController
OC:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController * nav = tabBarController.selectedViewController;
UIViewController *viewController = nav.viewControllers[0];