1

I am working on an iPhone/iPad application. Trying to load very large image in UIImage view stored in local directory in app. Code:

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];

In iPhone and Simulator images gets loaded perfectly but when I try to run app in iPod touch 4g it misses the image in UI Webview. I guess there are some memory issues. Not sure. Any help.

Image size is: 640*5000

Awais Tariq
  • 7,724
  • 5
  • 31
  • 54

1 Answers1

0

may be this link1 or link2 will help you

We tried with the code and its working,

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];
Community
  • 1
  • 1
chirag
  • 1,090
  • 9
  • 13