iOS加载Html文件时不能显示图片
来源:互联网 发布:简洁工单任务系统源码 编辑:程序博客网 时间:2024/05/24 05:06
本人加载的一段html代码,但是只有文字显示,但是图片不显示
html文件如下:
<!doctype html><html><head><meta charset="utf-8"><meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport" id="viewport" /><meta content="yes" name="apple-mobile-web-app-capable"><meta content="black" name="apple-mobile-web-app-status-bar-style"><meta content="telephone=no" name="format-detection"><title>无网络</title><style type="text/css">*{margin:0px;padding:0px;}.ww{padding:120px 0 0;}.ww span{width:100px;height:100px;margin:0 auto 40px;display:block;}.ww span img{width:100%;}.ww p{line-height:22px;color:#646060;text-align:center;font-size:20px;}</style></head><body><div class="ww"> <span><img src="ww.png"></span> <p>当前网络不可用,请稍后重试!</p></div></body></html>
加载的代码写在如下的方法里面
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
其中具体实现如下,希望参考,当然注意文件的路径啊
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { LILog(@"failed"); [_progressView stopAnimating]; NSString *filePath = [[NSBundle mainBundle]pathForResource:@"无网络" ofType:@"html"]; NSString *html = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error]; [wk loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]]; if (error.code == -1001) { //time out } else if (error.code == -1003) { // server cannot be found } else { // }}
希望能给大家帮助
0 0
- iOS加载Html文件时不能显示图片
- ios 加载本地HTML文件,图片不显示的问题
- html文件如何加载iOS本地图片
- iOS 加载本地HTML文件,图片没显示出来的问题
- webview加载的html文件,图片如何放大显示?
- webview加载的html文件,图片如何放大显示?
- html图片加载失败时显示默认图片
- ios html 加载本地图片
- SDWebImage 加载网络图片不能显示
- listview加载图片,导致最后一条item中ImageView加载图片时不能完全显示
- html help workshop 图片不能正常显示
- html img 加载错误时显示默认图片
- 利用WebView加载HTML代码时解决图片正常显示
- ios项目真机调试时图片不能显示
- 解决Outlook 2007中收发邮件HTML文件不能显示图片的方法
- TextView加载Html并且显示图片
- Android加载html内容显示图片
- TextView加载Html文本显示图片问题
- MyBatis传入多个参数的问题
- 基础六
- linux下onvif协议gsoap实现的源码(测试编译成功版)
- Swift 方法的形参写法
- java技术架构选型
- iOS加载Html文件时不能显示图片
- 单例的理解
- Animation动画详解(七)——ObjectAnimator基本使用
- Nginx配置文件nginx.conf中文详解
- Java四种线程池的使用
- pomelo中chat的简单总结
- 教程
- 我的常用代码
- Eclipse 打开时“发现了以元素'd:skin'”开头的无效内容。此处不应含有子元素