We basically load local file by this code:
WKPreferences *preferences = [[WKPreferences alloc] init];
[preferences setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
configuration.preferences = preferences;
// Create WKWebView
self.webView = [[WKWebView alloc] initWithFrame:self.window.contentView.bounds
configuration:configuration];
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSURL *htmlURL = [NSURL fileURLWithPath:[resourcePath stringByAppendingPathComponent:@"test.html"]];
NSURL *baseURL = [NSURL fileURLWithPath:resourcePath];
NSLog(@"Loading HTML from path: %@", htmlURL.path);
[self.webView loadFileURL:htmlURL allowingReadAccessToURL:baseURL];
if this approach is wrong, it wont load at all
Post
Replies
Boosts
Views
Activity
any feedbacks are welcomed!