search

Home  >  Q&A  >  body text

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 days ago214

reply all(1)I'll reply

  • 怪我咯

    怪我咯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

    reply
    0
  • Cancelreply