【问题标题】:Failed to load large image in UI Webview ios无法在 UI Webview ios 中加载大图像
【发布时间】:2013-03-30 11:49:06
【问题描述】:

我正在开发一个 iPhone/iPad 应用程序。尝试在应用程序本地目录中存储的 UIImage 视图中加载非常大的图像。代码:

NSString *path = [[NSBundle mainBundle] pathForResource:selectedImage ofType:@"jpg"];
NSString *cssString = @"<style type='text/css'>img {width: 100%; height: auto;} body { margin: 0; padding: 0; }</style>";
NSString *htmlString = [NSString stringWithFormat:@"<html><head>%@</head><body><img src=\"file://%@\" /></body></html>",cssString,path];
[webview loadHTMLString:htmlString baseURL:nil];

在 iPhone 和模拟器中,图像可以完美加载,但是当我尝试在 iPod touch 4g 中运行应用程序时,它会错过 UI Webview 中的图像。我想有一些内存问题。不确定。 任何帮助。

图片尺寸为:640*5000

【问题讨论】:

  • 确保图像名称与您在项目包中添加的图像名称相同 bcz 模拟器不区分大小写..
  • 这不是问题。 Iphone 4 完美加载。问题只出在 iPod 上

标签: iphone ios image memory uiwebview


【解决方案1】:

也许这个link1link2 会帮助你

我们尝试了代码及其工作,

NSString *path = [[NSBundle mainBundle]pathForResource:@"imageName" ofType:@"png"];
       NSString *_path = [[NSBundle mainBundle] bundlePath];
          NSURL *baseURL = [NSURL fileURLWithPath:_path];
      [self.webobj loadData:[NSData dataWithContentsOfFile ath] MIMEType:@"image/png" textEncodingName:@"UTF-8" baseURL:baseURL];

【讨论】:

    猜你喜欢
    • 2011-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多