2013-04-08 33 views
0

我正在研究iPhone/iPad應用程序。嘗試在應用程序的本地目錄中存儲的UIImage視圖中加載非常大的圖像。代碼:無法在用戶界面Webview中加載大圖像ios

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的觸摸4G運行程序的時候,錯過在UI網頁視圖圖像。我想有一些內存問題。不確定。 任何幫助。

影像尺寸爲:640 * 5000

+0

確保圖像的名字與您在項目包中添加的相同bcz Simulator不區分大小寫。 – 2013-04-08 12:07:50

+0

這不是問題。 Iphone 4完美加載。問題只與iPod有關 – 2013-04-08 12:43:42

回答

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