1、准备html文件,将文件夹命名为load_html_file;
2、导入到xcode,勾选Copy itmes if need和Creat folder references
在工程中的目录:
3、获取文件目录:
//获取URL方式1
NSURL *url = [[NSBundle mainBundle] URLForResource:@"/load_html_file/index.html" withExtension:nil];
//获取URL方式2
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"load_html_file"];
NSURL *pathURL = [NSURL fileURLWithPath:filePath];
4、加载到webview
[self.wv loadRequest:[NSURLRequest requestWithURL:pathURL]];
完毕!