iOS加载Html文件时不能显示图片

本人加载的一段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 {
        //
    }
}

希望能给大家帮助

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页