可以将该方法写到基类或者写到UIView分类当中
- (UIViewController *)getCurrentViewController {
UIResponder *next = self.nextResponder;
do {
//判断响应者是否为视图控制器
if ([next isKindOfClass:[UIViewController class]]) {
return (UIViewController *)next;
}
next = next.nextResponder;
} while (next != nil);
return nil;
}
网友评论