iOS读取本地html文件
首先创建一个web
然后将html文件加载到创建的web中,代码如下:
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"couponsInfo"
ofType:@"html"];
NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
encoding:NSUTF8StringEncoding
error:nil];
[self.web loadHTMLString:htmlCont baseURL:baseURL];
[self.view addSubview:self.web];