OC 加载一个本地HTML页面
2017-08-24 本文已影响46人
CodeLuck
简单记录,拿来备份
UIWebView * webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HIGHT+64)];
webView.backgroundColor = [UIColor clearColor];
[self.view addSubview:webView];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"用户协议"
ofType:@"html"];
NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
encoding:NSUTF8StringEncoding
error:nil];
[webView loadHTMLString:htmlCont baseURL:baseURL];