29,031
社区成员
发帖
与我相关
我的任务
分享
let webView = UIWebView(frame: CGRect(x: 0, y: 0,
width: self.view.bounds.size.width,
height: self.view.bounds.size.height))
self.view.addSubview(webView)
webView.autoresizingMask = .FlexibleHeight | .FlexibleWidth
let htmlFilePath = NSBundle.mainBundle().pathForResource("FileName", ofType: "html")!
// 1.
webView.loadData(NSData(contentsOfFile: htmlFilePath), MIMEType: "text/html", textEncodingName: "UTF-8", baseURL: nil)
// 2.
webView.loadHTMLString(NSString(contentsOfFile: htmlFilePath, encoding: NSUTF8StringEncoding, error: nil), baseURL: nil)