背景:AViewController 添加 BView,例如 [AViewController.view addSubview: bview],在BView类中获取AViewController控制器,实现跳转等功能。
具体实现:
- (AViewController *)vc {
UIView* aView = [self superview];
AViewController * vc = nil;
UIResponder * responder = aView.nextResponder;
if ([responder isKindOfClass:[AViewController class]]) {
vc = (AViewController *)responder;
}
return vc;
}