1. UIResponder
UIViewController *uvc; UIResponder* nextResponder = [self.superview.superview.superview nextResponder]; if ([nextResponder isKindOfClass:[UIViewController class]]) { uvc = (UIViewController*)nextResponder; }
2.获取当前屏幕中present出来的viewcontroller
- (UIViewController *)getPresentedViewController { UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController; UIViewController *topVC = appRootVC; if (topVC.presentedViewController) { topVC = topVC.presentedViewController; } return topVC; }