歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> UIWebView中顯示本地圖片的方法

UIWebView中顯示本地圖片的方法

日期:2017/3/1 10:11:05   编辑:Linux編程

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];
Copyright © Linux教程網 All Rights Reserved