pch文件中包含这个文件什么用?响应不是系统的事吗?

#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
阅读 1.9k
1 个回答

这是类别,通过代码可以看出这个类别的作用应该是通过 View 来拿到其所在控制器的对象,即 view.viewController

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题