Load local HTML file in webView
suggest changeFirst, add the HTML File to your Project (If you are asked to choose options for adding the file, select Copy items if needed)
The following line of code loads the content of the HTML file into the webView
webView.loadRequest(NSURLRequest(URL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("YOUR HTML FILE", ofType: "html")!})
- If your HTML file is called index.html replace YOUR HTML FILE with index
- You can use this code either in viewDidLoad() or viewDidAppear() or any other function
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents