标签:
直接上代码,简单易懂:
#import "UIView+UIViewController.h" @implementation UIView (UIViewController) - (UIViewController *)viewController { //通过响应者链,取得此视图所在的视图控制器 UIResponder *next = self.nextResponder; do { //判断响应者对象是否是视图控制器类型 if ([next isKindOfClass:[UIViewController class]]) { return (UIViewController *)next; } next = next.nextResponder; }while(next != nil); return nil; } @end
iOS 获取view的controller UIView+UIViewController
标签:
原文地址:http://blog.csdn.net/xy_26207005/article/details/51260919