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
finally! I Know where went wrong!! When you want to load a new and different file, make sure it's in the same directory as the first load file.
eg.
NSString *pathA = "file:///path/to/abc/dirA/A.html";
NSString *pathB = "file:///path/to/abc/dirB/B.html";
NSString *pathC = "file:///path/to/abc/dirC/C.html";
NSURL *url = [NSURL fileURLWithPath:pathA];
NSURL *readAccessToURL = [[url URLByDeletingLastPathComponent] URLByDeletingLastPathComponent];
// readAccessToURL == "file:///path/to/abc/"
[self.wk_webview loadFileURL:url allowingReadAccessToURL:readAccessToURL];
// then you want load pathB
url = [NSURL fileURLWithPath:pathB];
// this will work fine
[self.wk_webview loadFileURL:url allowingReadAccessToURL:readAccessToURL];