1

我正在开发一个 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

4

1 回答 1

0

可能这个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];
于 2013-04-08T13:18:39.147 回答