tags:

views:

116

answers:

1

I m the beginner in iphone development.

How i call the background image from my project directory in Xcode in html page. I have taken previously UISegment control and after that i calling two html page on webview in uisegmentcontroller. Now i want to set background images on those html pages. It is possible? if it is yes then how?

thanks in advance..

A: 

You can specify a base URL when loading HTML in a UIWebView. If you set the base URL to your bundle path, you can simply reference the background image as if it was in the current directory.

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

[webView loadHTMLString:htmlPage baseURL:baseURL];

in your HTML:

body { 
  background: url(bg.jpg); // "bg.jpg" is in your bundle
}
Philippe Leybaert
http://iphoneincubator.com/blog/windows-views/uiwebview-revisited
slf