首页 > 代码库 > 通过当前view得到所在的viewcontroller

通过当前view得到所在的viewcontroller

 1 @implementation UIView (GetVCAdditions) 2  3 - (UIViewController *)GetiewController { 4     Class vcc = [UIViewController class]; 5     UIResponder *responder = self; 6     while ((responder = [responder nextResponder])) 7         if ([responder isKindOfClass: vcc]) 8             return (UIViewController *)responder; 9     return nil;10 }

 

通过当前view得到所在的viewcontroller