标签:
- (UIViewController *)currentController {
UIViewController *result = nil;
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
if (window.windowLevel != UIWindowLevelNormal) {
NSArray *windows = [[UIApplication sharedApplication] windows];
for (UIWindow *temWin in windows) {
if (temWin.windowLevel == UIWindowLevelNormal) {
window = temWin;
break;
}
}
}
UIView *frontView = [[window subviews] objectAtIndex:0];
id nestResponder = [frontView nextResponder];
if ([nestResponder isKindOfClass:[UIViewController class]]) {
result = nestResponder;
} else {
result = window.rootViewController;
}
return result;
}
标签:
原文地址:http://www.cnblogs.com/rollrock/p/5630929.html