2010-11-18 36 views
0

嘿,我的iPhone應用程序內有一個webView。 webView在服務器上打開一個html頁面(不在iPhone上)。 現在該網站包含一個html圖像。由於iPhone不緩存,並加載速度慢,我喜歡將HTML圖像鏈接到我的應用程序中的本地資源。iPhone - 在本地資源的HTML頁面中的鏈接圖片圖片

有誰知道如何做到這一點?這甚至可能嗎?

+0

這個帖子看看,以幫助你通過一些陷阱http://stackoverflow.com/questions/478665/link-to-resources - 內部-WebView的iphone – 2010-11-18 18:27:06

回答

0
NSString *localPng = [[NSBundle mainBundle] pathForResource:@"item" 
                 ofType:@"png"]; 
NSData *htmlData = [NSData dataWithContentsOfFile:localPng]; 
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" 
              baseURL:[NSURL URLWithString:@""]];