The Dude
The Dude

Reputation: 41

Is there any way to load local images in WKWebView?

i'm creating an application that generates invoice .It uses html and javascript.Every thing is working perfectly but it is not showing logo image.Any help would be appreciated.

Upvotes: 0

Views: 232

Answers (1)

Supersheep
Supersheep

Reputation: 256

You can load resources from your app's bundle via a custom URL scheme, e.g. my_url_scheme://logo.png (replace my_url_scheme with something unique of your choice).

You need to implement a WKURLSchemeHandler and registering it with your WKWebView via -[WKWebViewConfiguration setURLSchemeHandler:forURLScheme:]. Your WKURLSchemeHandler will be responsible for handling any requests with the my_url_scheme:// scheme, and can load the appropriate resource from the app's bundle and return it there.

Upvotes: 0

Related Questions