#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;
}