#import "UIView+UIViewController.h"
@implementation UIView (UIViewController)
-(UIViewController *)viewController{
UIResponder *next = self.nextResponder;
while(next !=nil){
if([next isKindOfClass:[UIViewController class]]){
return (UIViewController *)next;
}
next = next.nextResponder;
}
return nil;
}
@end
怪我咯2017-04-17 17:39:07
This is a category. It can be seen from the code that the function of this category should be to get the object of its controller through View, that is, view.viewController