【问题标题】:iOS: Couldn't link HTML string loaded from sqlite db with images in bundliOS:无法将从 sqlite db 加载的 HTML 字符串与 bundle 中的图像链接
【发布时间】:2012-03-22 06:15:34
【问题描述】:

如何将从 sqlite db 加载的 HTML 字符串与存储在 bundle 中的图像链接

[self.wbvuContents loadHTMLString:self.page baseURL:nil];

self.page 可能如下:

<html>
<body>
<div  style='margin:20 0 0 0px'>  <img style=' ' alt='' height='48' src='images/01-01-018.jpg' width='75' /> 
</body>
</html>

01-01-018.jpg 图像被添加到包中

当使用上面的代码图片时webview中没有出现

【问题讨论】:

    标签: iphone html ios image uiwebview


    【解决方案1】:
    NSString *path;
    NSURL *baseURL;
    path = [[NSBundle mainBundle] bundlePath];
    myBaseURL = [NSURL fileURLWithPath:path];
    
    [self.wbvuContents loadHTMLString:self.page baseURL:myBaseURL];
    

    那么,如果您的图片 01-01-018.jpg 在您的捆绑包中:

    <html>
    <body>
    <div  style='margin:20 0 0 0px'>  <img style=' ' alt='' height='48' src='01-01-018.jpg' width='75' /> 
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-25
      • 2015-10-06
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-03
      相关资源
      最近更新 更多