获得view所在的控制器

- (UIViewController*)getViewController{

    

    for (UIView* next = [self superview]; next; next = next.superview) {

        UIResponder* nextResponder = [next nextResponder];

        if ([nextResponder isKindOfClass:[UIViewController class]]) {

            return (UIViewController*)nextResponder;

        }

    }

    return nil;

 

}

你可能感兴趣的:(获得view所在的控制器)