UIWebview和WKWebview加载本地html
来源:互联网 发布:西安办公软件培训班 编辑:程序博客网 时间:2024/05/21 09:58
情况一 html文件不在文件夹里
NSURL *url = [[NSBundlemainBundle] URLForResource:@"test"withExtension:@"html"];
NSURLRequest *request = [NSURLRequestrequestWithURL:url];
[_webView loadRequest:request];
情况二 html文件在文件夹里
1 添加文件夹时 选择Create folder references
//////// 对于UIWebview的加载方法
@———1
NSString *documentPath=[[NSBundlemainBundle]bundlePath];
NSString *filePath = [NSStringstringWithFormat:@"%@%@",documentPath,@"/video-js/index.htm"];
NSString *htmlString = [NSStringstringWithContentsOfFile:filePathencoding:NSUTF8StringEncodingerror:nil];
NSString *filePath = [NSStringstringWithFormat:@"%@%@",documentPath,@"/video-js/index.htm"];
NSString *htmlString = [NSStringstringWithContentsOfFile:filePathencoding:NSUTF8StringEncodingerror:nil];
[self.newsWebViewloadHTMLString:htmlStringbaseURL:[NSURLURLWithString:filePath]];
@———2
NSString *documentPath=[[NSBundlemainBundle]bundlePath];
NSString *filePath = [NSStringstringWithFormat:@"%@%@",documentPath,@"/video-js/index.htm”];
NSString *filePath = [NSStringstringWithFormat:@"%@%@",documentPath,@"/video-js/index.htm”];
[_webViewloadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:filePath]]];
//// 对于WKWebview的加载方法
NSString *documentPath=[[NSBundlemainBundle]bundlePath];
NSString *filePath = [NSStringstringWithFormat:@"%@%@",documentPath,@"/video-js/index.htm"];
NSString *htmlString = [NSStringstringWithContentsOfFile:filePathencoding:NSUTF8StringEncodingerror:nil];
[self.newsWebViewloadHTMLString:htmlStringbaseURL:[NSURLURLWithString:@"file:///video-js/"]];
NSString *filePath = [NSStringstringWithFormat:@"%@%@",documentPath,@"/video-js/index.htm"];
NSString *htmlString = [NSStringstringWithContentsOfFile:filePathencoding:NSUTF8StringEncodingerror:nil];
[self.newsWebViewloadHTMLString:htmlStringbaseURL:[NSURLURLWithString:@"file:///video-js/"]];
上一行的 baseURL ::: [NSURL URLWithString:@"file:///文件所在的文件夹名称/"]
如果加载不出来 断点打印路径,,使用前往文件夹的方法看能不能成功进入,,调整路径拼接直到可以前往便能成功加载
阅读全文
0 0
- UIWebview和WKWebview加载本地html
- WKWebView和UIWebView加载本地html和JS交互各种坑解决办法
- UIWebView加载本地html
- UIWebView加载本地html
- UIWebView加载本地html
- UIWebView加载本地html
- UIWebview和WKWebview的使用 js交互 本地加载 网络加载
- UIWebView加载本地HTML文件
- UIWebView加载本地html ios
- UIwebview加载本地html文件
- UIWebView加载本地HTML文件
- UIWebview加载本地html文件
- UIWebView和WKWebView
- Swift UIWebView 和 WKWebView
- WKWebView和UIWebView
- WKWebView 和UIWebView
- UIWEBVIEW和WKWebView学习
- UIWebView和WKWebView 改变HTML 图片尺寸 及 字体大小
- mysql 删除表记录 delete和truncate table区别
- linux入门必知
- 论文阅读笔记:U-Net: Convolutional Networks for Biomedical Image Segmentation
- andriod——Retrofit+Fresco+MVP+Fragment判断网络获取数据
- 实时收集文件框架之Flume
- UIWebview和WKWebview加载本地html
- 网络编程1
- 函数式编程入门教程
- static,this,self,parent
- Mac下安装Jekyll
- Android学习资料、博客、网站、公众号等平台总结推荐分享
- <%@include>与<jsp:include>区别
- Win10 环境变量配置
- Jmeter聚合报告分析