iOS讀取本地html文件
首先創(chuàng)建一個(gè)web
然后將html文件加載到創(chuàng)建的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];