【问题标题】:iPhone - Link Image in html page in local resource ImageiPhone - 在本地资源图像的 html 页面中链接图像
【发布时间】:2011-05-12 05:04:06
【问题描述】:

嘿,我的 iPhone 应用程序中有一个 webView。 webView 在服务器上打开一个 html 页面(不在 iPhone 上)。 现在该网站包含一个 html 图像。由于 iPhone 没有缓存并且加载缓慢,我喜欢将 html 图像链接到我的应用程序中的本地资源。

有人知道怎么做吗?这可能吗?

【问题讨论】:

标签: iphone objective-c ipad


【解决方案1】:
NSString *localPng = [[NSBundle mainBundle] pathForResource:@"item"
                                                       ofType:@"png"];
NSData *htmlData = [NSData dataWithContentsOfFile:localPng];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8"
                                             baseURL:[NSURL URLWithString:@""]]; 

【讨论】:

    【解决方案2】:

    您可以尝试它是 HTML 中的“file://item.png”。图片必须放在你的捆绑包中 - 我认为。

    试试看这篇文章:

    http://www.iphonedevsdk.com/forum/iphone-sdk-development/1784-how-can-i-access-local-html-file-using-uiwebview.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-12
      • 2013-06-01
      • 1970-01-01
      • 2011-02-01
      • 1970-01-01
      • 2018-02-09
      • 1970-01-01
      • 2013-09-19
      相关资源
      最近更新 更多