0

I am trying to display local image onto the UIWebView. This web view is generated with HTML code locally. I am using the following code:

[htmlPage appendStringWithFormat:@"< img src=\"%@\" alt=\"image\" height=\"100\" 

width=\"100\"/>",[[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"png"];
ThomasCle
  • 6,792
  • 7
  • 41
  • 81
Raju goud Bingi
  • 160
  • 2
  • 13
  • 1
    Look at this question: [Using HTML and Local Images Within UIWebView](http://stackoverflow.com/questions/747407/using-html-and-local-images-within-uiwebview) – RoLife Sep 04 '13 at 06:14

1 Answers1

2

You need to load your HTML into the webview with

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[webView loadHTMLString:htmlString baseURL:baseURL];

Then your HTML should reference the image like so:

body {
    background-image:url('img/myBg.png');
}
Woodstock
  • 22,184
  • 15
  • 80
  • 118