iOS WebView 载入CSS的Background-image失败

Gist: https://gist.github.com/bolasblack/7260065

代码:

<style>
  html, body {
    margin: 0;
    padding: 0;
  }
  #qingchuang {
    margin: 0;
    padding: 0 15px;
    width: 270px;
    font: 15px/1.5 "Helvetica Neue", Helvetica, \5FAE\8F6F\96C5\9ED1, tahoma, arial, \5b8b\4f53, Verdana, Geneva, sans-serif, "Myriad Pro";
    text-align: left;
    background: #f7f6f2;
    color: #3a3a3a;
  }

  #qingchuang a {
    color: #0085c6;
    text-decoration: none;
  }

  #qingchuang ul {
    margin: 0;
    padding: 0;
  }

  #qingchuang li {
    list-style: none;
  }

  #qingchuang li.media {
    border-bottom: 1px solid #e2e2e2;
  }

  #qingchuang .media {
    overflow: hidden;
    zoom: 1;
    padding: 13px 0;
  }

  #qingchuang .media-object {
    margin-right: 13px;
  }

  #qingchuang .media-body {
    overflow: hidden;
    zoom: 1;
  }

  #qingchuang .media-body li {
    padding-left: 28px;
    margin-bottom: 5px;
  }

  #qingchuang .name,
  #qingchuang .tel,
  #qingchuang .mail {
    background-position: left center;
    background-repeat: no-repeat;
  }

  #qingchuang .name {
    background-image: url("http://images.appatom.com/b004809c83f734aa61a2f26ed5d661a4");
  }
  #qingchuang .tel {
    background-image: url("http://images.appatom.com/0e572a65e945a3131fa59993d0533422");
  }
  #qingchuang .mail {
    background-image: url("http://images.appatom.com/ef9b7a5d50e6a832363df22804d2221f");
  }

  #qingchuang .pull-left {
    float: left;
  }
</style>

<div id="qingchuang">
  <ul>

    <li class="media">
      <img src="http://images.appatom.com/d04748e7213aaebde9e7cde30c8b749c" class="media-object pull-left" width="75" height="75">
      <ul class="media-body">
        <li class="name">名称</li>
        <li class="tel">
          <a href="tel:11111111111">11111111111</a>
        </li>
        <li class="mail">
          <a href="mailto:example@example.com">example@example.com</a>
        </li>
      </ul>
    </li>

  </ul>
</div>

在程序里,这段 HTML 是以字符串形式获取到,然后写入 WebView 的:

NSString* htmlString = [NSString stringWithFormat:@"<!DOCTYPE html><html><body>%@</body></html>",content];
            NSLog(@"%@",htmlString);
            [_webView loadHTMLString:htmlString baseURL:nil];

content 就是上述的 html 。

当 WebView 载入完成后,发现 .name, .tel, .mail 三个类的背景图片都没有被加载

大家遇到过这样的问题吗?

查看回复