iOS 之 获取View所在控制器

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;
}
上一篇:《zw版·Halcon-delphi系列原创教程》halconxlib控件列表


下一篇:SQL serve 聚合函数、字符串函数