用ios上用webview加载了一个本地的HTML文件,代码如下
//load test.html 到 webview
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSString *filePath =[resourcePath stringByAppendingPathComponent:@"test.html"];
NSString*htmlstring=[[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[myWebView loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath:[ [NSBundle mainBundle] bundlePath]]];
test.html 内容如下
Page Title
jsToNative
nativeToJs
JS 调用 Native
This is a paragraph.