UIWebView加载一个静态的HTML文件

前端之家收集整理的这篇文章主要介绍了UIWebView加载一个静态的HTML文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<table class="text"><tr class="li1">
<td class="ln"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

文件加入到项目之中   class WebViewController: UIViewController {       override func viewDidLoad() {         super.viewDidLoad()         //检查 BullsEye.html是否存在         if let htmlFile = NSBundle.mainBundle().pathForResource("BullsEye",ofType: "html"){               let htmlData = NSData(contentsOfFile: htmlFile)               let baseURL = NSURL.fileURLWithPath(NSBundle.mainBundle().bundlePath)               web.loadData(htmlData,MIMEType: "text/html",textEncodingName: "UTF-8",baseURL: baseURL)         }     }         //UIWebView     @IBOutlet weak var web: UIWebView!   }

猜你在找的程序笔记相关文章