获取当前屏幕显示的viewcontroller
2016-06-03 15:30
363 查看
#pragma mark 获取当前屏幕显示的viewcontroller /** * @author zm * @brief 获取当前屏幕显示的viewcontroller * @return 当前的ViewController(未找到返回nil) */ - (UIViewController *)f_getCurrentViewController { UIViewController *_vc_result =nil; UIWindow *_w_current = [[UIApplicationsharedApplication] keyWindow]; if (_w_current.windowLevel !=UIWindowLevelNormal) { NSArray *arr_windows = [[UIApplicationsharedApplication] windows]; for(UIWindow * _w_tempin arr_windows) { if (_w_temp.windowLevel ==UIWindowLevelNormal) { _w_current = _w_temp; break; } } } UIView *_v_front = [[_w_currentsubviews] objectAtIndex:0]; id _id_nextResponder = [_v_frontnextResponder]; if ([_id_nextResponderisKindOfClass:[UIViewControllerclass]]) _vc_result = _id_nextResponder; else _vc_result = _w_current.rootViewController; return _vc_result; }
相关文章推荐
- TCP中 recv和sendf函数
- 浮点数转换成字符串函数
- 《剑指offer》:[11]旋转数组的最小数字
- 从零开始构建MSBuild C#项目文件
- log4j详细配置
- 读取data/data/ccc.apl(忘了出处)
- jar包更新到远程仓库
- SVN安装
- iOS笔记—NSURLConnection怎么把http改为https
- Python数据类型转换
- 存储过程中日期格式的转换
- 以Yii 2.0风格加载自定义类或命名空间 [配置使用Yii autoloader] [ 2.0 版本 ]
- Hibernate与Ibatis比较
- Intent和IntentFilter详解
- 笔记:Linux 常用命令
- 敏捷开发之Scrum
- Unable to enable crypto on TCP connection make sure the sslcafile or sslcapath option are properly
- Python 字典详解
- Java中的隐藏和覆盖
- eclipse安装Pydev插件,安装成功后不显示的问题