如何根据View获取所在的Controller

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shaohua_lv/article/details/78781244

根据View获取当前的UIViewController

- (UIViewController *)viewControllerSupportView:(UIView *)view {
    for (UIView* next = [view superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}
展开阅读全文

没有更多推荐了,返回首页