UIWebView *webView = [[UIWebViewalloc]initWithFrame:CGRectMake(0,0, frame.size.width, frame.size.width)];
webView.delegate =self;
NSString *path = [[NSBundlemainBundle]pathForResource:@"我是本地网页"ofType:@"html"];//该文件要手动加入项目中才能获取
NSString *htmlStr = [NSStringstringWithContentsOfFile:pathencoding:NSUTF8StringEncodingerror:nil];
[webView loadHTMLString:htmlStr baseURL:[NSURL URLWithString:path]];
[viewaddSubview:webView];
本文介绍如何使用UIWebView加载本地HTML文件,并展示了具体的实现代码。通过NSBundle获取资源路径,读取HTML字符串并加载到UIWebView中。
812

被折叠的 条评论
为什么被折叠?



