求助!!!!!
最近刚接手新公司的项目,他们用的是H5混合开发模式,最近突击了一下,还是有些问题
- (void)injectJavaScriptToHTML {
_JSContext = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
_JSContext.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue) {
context.exception = exceptionValue;
NSLog(@"异常信息:%@", exceptionValue);
};
[self evaluatingJavaScript];
}
- (void)evaluatingJavaScript {
[self evaluatingJavaScriptForResource:@"workplat" ofType:@"js"];
}
- (void)evaluatingJavaScriptForResource:(NSString *)resource ofType:(NSString *)type {
NSBundle *bundle = [NSBundle bundleForClass:[FBJavaScriptInterface class]];
NSURL *url = [bundle URLForResource:@"FBWebViewController" withExtension:@"bundle"];
NSString *jsPath = [[NSBundle bundleWithURL:url] pathForResource:resource ofType:type];
NSString *jsStr = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:nil];
[self.webView stringByEvaluatingJavaScriptFromString:jsStr];
}
- (void)setupJSOpenWebView {
__weak FBJavaScriptInterface *safeSelf = self;
self.JSContext[@"openWindow"] = ^(NSString *url, BOOL showTopMenu, BOOL showCloseButton, BOOL showBackButton, NSString *title, NSString *func_name)
{
这个方法不执行!!!!
}
};
}
大概就是这样,基本的初始化应该没问题的,就是像这样的调用方法不执行,方法名和js里的一样的,可能会是什么原因呢 声明safeself的那行代码是走的