在View中对Button的触发事件或者didSelectRow都无法直接进行跳转到ViewController;
在这里就用代理来实现
1.首先在View的.h文件中
@protocol RecognitionResultViewDelegate <NSObject>
-(void)GoAskQuestionPushVC;
@optional
@end
@interface RecognitionResultView : UIView
@property(nonatomic,assign)id<RecognitionResultViewDelegate>delegate;
@end
2.在View.m中的触发方法里
[self.delegate GoAskQuestionPushVC];、
3.在VIewController中
1️⃣@interface RecognitionResultViewController ()<RecognitionResultViewDelegate>
2️⃣ _recognitionV.delegate = self;
3️⃣
- (void)GoAskQuestionPushVC {
AskQuestionViewController *askVC = [[AskQuestionViewController alloc]init];
[self.navigationController pushViewController:askVC animated:YES];
}
就这么简单就可以实现在View中跳转到ViewControlelr的功能了