UIWebView中显示本地图片的方法


UIWebView中显示本地图片的方法:

html内容如下:

  1. <html>  
  2.     Opening Hours:<br/>  
  3.     Monday to Friday 7am and 7pm<br/>  
  4.     Saturday from 8am until 12noon<br/><br/>  
  5.     Northcross Physiotherapy and Rehabilitation is a Physiotherapy Private Practice situated in the Northcross Specialist Centre. This is a private company established by it's current principle. The practice's primary activity involves the provision of specialist physiotherapy services and education to the local population. This has been in operation at the current site since June 1997 and at premises closer to the Albany Village since 1991. As well as this website, Northcross Physiotherapy also has a Trade Me listing.<br/>  
  6.     <img src="about.png" width="320" height="241"/>  
  7. </html> 

about.png和html文件在同一个目录下。

示例:

  1. NSString *path = [[NSBundle mainBundle] bundlePath];   
  2. NSURL *baseURL = [NSURL fileURLWithPath:path];   
  3. NSString *htmlString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"about" ofType:@"html"]  encoding:NSUTF8StringEncoding error:nil];   
  4. [self.webView loadHTMLString:htmlString baseURL:baseURL]; 

相关内容