如何递归获取某一个view的controller

2017-03-05  本文已影响21人  F麦子

//获取view的controller

- (UIViewController*)viewController{

for(UIView* next = [selfsuperview]; next; next = next.superview) {

           UIResponder *nextResponder = [next nextResponder];

            if([nextResponder isKindOfClass:[UIViewControllerclass]]) {

                     return(UIViewController*)nextResponder;

           }

   }

    returnnil;

}

上一篇下一篇

猜你喜欢

热点阅读