搜索

首页  >  问答  >  正文

ios - 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
PHPzPHPz2888 天前218

全部回复(1)我来回复

  • 怪我咯

    怪我咯2017-04-17 17:39:07

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

    回复
    0
  • 取消回复