iOS UIWebView Load local HTML file in webView

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

First, 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


Got any iOS Question?