Home > Web Front-end > HTML Tutorial > UIWebView loads a static HTML file_html/css_WEB-ITnose

UIWebView loads a static HTML file_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:40:06
Original
1014 people have browsed it

Now there is a static HTML file that I want to display in UIWebView. The code is very simple, as follows:

swift// 首先呢要把这个HTML文件加入到项目之中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!}
Copy after login

OK, then run the APP and you will see this static HTML page.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template