iOS基础·OC高级篇OC学习

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];

参考链接 详细了解的可以看这里

上一篇下一篇

猜你喜欢

热点阅读