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 と Simulator ではイメージが完全に読み込まれますが、iPod touch 4g でアプリを実行しようとすると、UI Webview でイメージが表示されません。メモリの問題もあると思います。わからない。どんな助けでも。

画像サイズ: 640*5000

4

1 に答える 1

0

このlink1またはlink2があなたを助けるかもしれません

コードとその動作を試してみました。

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 に答える