在iOS 开发中,难免会使用到web中的交互
这样我们就要获取交互中的事件了
这样我们就要获取交互中的事件了
@protocol ESendWebDelegate <JSExport>
- (void)backUserHome:(NSString *)backBtnAction;
@end
签好代理<ESendWebDelegate>
///backUserHome是js中的方法名
- (void)backUserHome:(NSString *)backBtnAction{
//在此处写点击web中的点击事件
[self.navigationController popToRootViewControllerAnimated:YES];
}
-(void)jsContext{
self.jsContext = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
self.jsContext[@"bizSendApply"] = self;
self.jsContext.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue){
context.exception = exceptionValue;
NSLog(@"异常信息:%@", exceptionValue);
};
}