I need to load a local file in a WKWebView. I\'m using the new ios9 method
- (nullable WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)re
I had a very similar problem as yours, but in my case I had a reference to WKWebView objects in UIViewCell objects (I have migrated from UIWebView recently).
I was reusing WKWebView objects because of the performance reasons (standard dequeue reusable thing).
To make a long story short, you have a allowingReadAccessToURL parameter in loadFileURL:allowingReadAccessToURL: method that tells WKWebView what are allowed paths when it loads a local file. From some reason, it doesn't care about this parameter when some page with a different allowingReadAccessToURL parameter is loaded. So I recommend to use the entire Documents path space as a default parameter to this method:
NSURL *documentsURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] objectAtIndex:0];
[self loadFileURL:request.URL allowingReadAccessToURL:documentsURL];
Hope it helps.