HomeiPhone UpdatesWKWebView. Load HTML File from App Bundle.

WKWebView. Load HTML File from App Bundle.


In Swift, you may load HTML information into your WKWebView from a file that’s a part of your App Bundle. Earlier than you utilize the under code snippet, please make it possible for the HTML file you need to show in WKWebView is added to your challenge.

Load Native HTML File to a WKWebView

let myUrl = myProjectBundle.url(forResource: "my-html-file", withExtension: "html")!
myWebView.loadFileURL(myUrl,allowingReadAccessTo: myUrl)

the place:

my-html-file – is the identify of HTML file you need to load into WKWebView out of your App Bundle. Please notice there is no such thing as a want to offer file extension right here.
myWebView – is an occasion of WKWebView

For extra Swift code examples and tutorials, please test the Swift Code Examples web page on this web site.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments