iOS 加载本地的html文件

 方法1:

self.webView  = [[UIWebView alloc]initWithFrame:self.view.bounds];
NSString *path = [[NSBundle mainBundle]pathForResource:@"index" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:html baseURL:nil];
[self.view addSubview:self.webView];

方法2:

NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:html baseURL:baseURL];
原文地址:https://www.cnblogs.com/hualuoshuijia/p/5725308.html