UIWebView和WKWebView一些琐事
2024-10-07 11:37:28
1.load加载 ,去本地查找html路径方式
NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];//这种方式不会去工程中蓝色folder中查找html
NSString *strRoot = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"deploy"];
//strRoot=/Users/liuwei/Library/Developer/CoreSimulator/Devices/3AD005A6-3D89-415E-84E6-797021F9A35E/data/Containers/Bundle/Application/C4379CFE-A113-480C-AF45-BDF7F8645EC3/WKWebView加载本地html.app/deploy
2.[NSURL fileURLWithPath:htmlPath] 和 [NSURL URLWithString:htmlPath]的区别
NSLog(@"htmlPath--%@",htmlPath);
NSLog(@"fileURLWithPath--%@,URLWithString--%@",[NSURL fileURLWithPath:htmlPath],[NSURL URLWithString:htmlPath]);
//htmlPath--/var/containers/Bundle/Application/0F25B57D-11D1-414D-B8CF-9CF7B66B0D59/WKWebView加载本地html.app/deploy/index.html
//fileURLWithPath--file:///var/containers/Bundle/Application/0F25B57D-11D1-414D-B8CF-9CF7B66B0D59/WKWebView%E5%8A%A0%E8%BD%BD%E6%9C%AC%E5%9C%B0html.app/deploy/index.html,URLWithString--(null)
3.有人说WKWebView加载本地html,9.0以前不能用loadRequest直接load, 需要先拷贝到沙盒文件夹里去。 http://www.jianshu.com/p/ccb421c85b2e
但是我发现仍然可以加载。不管NSURL用的是fileURLWithPath还是URLWithString, 用 [webView loadRequest:[NSURLRequest requestWithURL:fileURL]];
都能加载出来。
4.断网情况下,UIWebView是加载不了内容的, 除非加入一些3方插件,处理缓存。如JWCacheURLProtocol
我们项目 ,h5做了manfest缓存, 断网情况下仍然可以加载部分内容, 不需要用3方插件做任何其他缓存处理。
5.缓存策略那个超时时间设置是没有作用的。
未完...
最新文章
- SwipeMenuListView在ScrollView里上下滑动导致菜单不能显示完全的bug解决方法
- SQL 语句格式
- vmware 安装 macos
- 重新想象 Windows 8 Store Apps (45) - 多线程之异步编程: IAsyncAction, IAsyncOperation, IAsyncActionWithProgress, IAsyncOperationWithProgress
- IOS应用程序生命周期的AppDelegate详解
- gdb调试大全
- React组件生命周期过程说明【转】
- 执行curl -sSL 提示curl: (35) SSL connect error
- MongoDB学习笔记05
- haproxy image跳转 haproxy匹配 匹配到了就停止,不会继续往下匹配
- ajax的get与post提交方式
- qt数据库多线程问题的解决(QSqlDatabase只能在创建它的线程中使用)
- javascript笔记整理(正则)
- c语言,enum
- flume日志采集
- Android studio导入eclipse项目(亲测)
- Pycharm常用的使用方法
- 基本 SQL 之增删改查(二)
- if 嵌套if 的先后顺序的区别 (自测)
- Mockito各场景使用介绍