獲取view所在的ViewController

weixin_34279579發表於2018-11-06
- (UIViewController *)handleFirstViewController {
   return [self traverseResponderChainForUIViewController];
}
- (id)traverseResponderChainForUIViewController {
  id next = [self nextResponder];
   if ([next isKindOfClass:[UIViewController class]]) {
       return next;
   } else if ([next isKindOfClass:[UIView class]]) {
       return [next traverseResponderChainForUIViewController];
   } else {
       return nil;
   }
}

相關文章