WKWebView 解决跨域问题
2018-07-19 本文已影响0人
lindong
WKUserContentController *userContentController = [[WKUserContentController alloc] init];
[self registerAllJavascriptWithUserContent:userContentController];
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.userContentController = userContentController;
config.preferences.javaScriptEnabled = YES;
config.preferences.javaScriptCanOpenWindowsAutomatically = YES;
config.suppressesIncrementalRendering = YES; // 是否支持记忆读取
[config.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
if (@available(iOS 10.0, *)) {
[config setValue:@YES forKey:@"allowUniversalAccessFromFileURLs"];
}