无敌获取控制器
2016-07-21 17:28
246 查看
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];
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];
相关文章推荐
- 编程小程序:1.编写程序,每次程序运行,产生5组双色球号码。每组号码升序排列,至少写出三种排序方法。
- oracle with as用法
- JS和CSS互动
- 委托及多播委托
- 逆向分析isKindOfClass 内部实现
- 利用Python实现选择排序
- css中的float知识点总结
- 出现Error: could not find java 2 Runtime Environment错误的处理!!
- ffmpeg 捕获屏幕和采集声卡、摄像头、麦克风声音
- MySQL存储引擎中的MyISAM和InnoDB区别详解
- 推荐系统 - 3 - 协同过滤算法、随机游走算法
- python学习
- 双击jar文件运行程序
- Java 字节码 工具 javassist
- sql语句备忘:非int类型行转列
- jquery datatables双击,获取行号。
- python模块
- DOM表格对象
- memcache设置set过期时间
- BootStrap 按钮