【问题标题】:Pick image from resource and load into web view从资源中选择图像并加载到 Web 视图中
【发布时间】:2012-07-12 11:56:49
【问题描述】:

我在资源的 ABC 文件夹中有一个图片说 point.png。

我想在 html 中显示该图像

NSString *myFilePath=   [[NSBundle mainBundle] pathForResource:@"Point1" ofType:@"png"];
NSMutableString *strForWebView = [NSString stringWithFormat:@"<html>"
                                          "<head><b>%@</b></head><br>"
                                          "<img src= %@ height='30' width='30' />"
                                          , [[play quotations] objectForKey:@"Heading"], myFilePath, .......

所以现在我应该怎么做才能选择图像的路径...in html 从中加载它在 web 视图中...

请帮忙

谢谢

【问题讨论】:

  • 转到此链接。我希望这会对你有所帮助 http://[stackoverflow.com/questions/6420925/load-resources-from-relative-path-using-local-html-in-uiwebview][1] [1]: stackoverflow.com/questions/6420925/…

标签: iphone uiwebview resourcebundle


【解决方案1】:

您的方法对于提供正确的 baseUrl 来加载 webView 至关重要。

如果您需要非本地基本 url 来加载一些外部数据,请考虑通过 base64 演示显示图像,我在this 回答中详细说明了如何做到这一点。

在此线程的 OP 中,您还将看到如果您只想显示本地内容,则必须如何使用基本 url。

【讨论】:

    猜你喜欢
    • 2015-03-20
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多