Re: WKWebView does not load images


Gerriet M. Denkmann
 

On 6 Oct 2017, at 23:29, Jens Alfke <jens@...> wrote:

On Oct 6, 2017, at 7:58 AM, Gerriet M. Denkmann <g@...> wrote:

htmlString contains: …<img alt=“alternate” src=“/path/to/myImage.gif” /> ….

WKWebView just shows a rectangle containing: “alternate”.
WKWebView has more security, so it probably disallows filesystem access. Or at least you may need to configure something about the “origin” or “security domain” to enable it. Or setting the baseURL to a “file:” URL might help.
The only way I can make WKWebView work properly is:

htmlString = …
write htmlString to tempUrl
[ wkWebView loadFileURL: tempUrl allowingReadAccessToURL: common root of tempUrl and imagesUrl ]

I do not like this at all. So I’ll better stick with WebView until WKWebView gets smarter.

Gerriet.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.