検索

ホームページ  >  に質問  >  本文

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日前216

全員に返信(1)返信します

  • 怪我咯

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

    これはカテゴリです。コードから、このカテゴリの機能は View を通じてそのコントローラのオブジェクトを取得することであることがわかります。つまり、view.viewController

    返事
    0
  • キャンセル返事