OGeek|极客世界-中国程序员成长平台

标题: iphone - iOS:无法将从 sqlite db 加载的 HTML 字符串与 bundle 中的图像链接 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:15
标题: iphone - iOS:无法将从 sqlite db 加载的 HTML 字符串与 bundle 中的图像链接

如何将从 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中没有出现



Best Answer-推荐答案


NSString *path;
NSURL *baseURL;
path = [[NSBundle mainBundle] bundlePath];
myBaseURL = [NSURL fileURLWithPath:path];

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

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

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

关于iphone - iOS:无法将从 sqlite db 加载的 HTML 字符串与 bundle 中的图像链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9817330/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4