WKWebView自适应大小
作者:
FANTASIED | 来源:发表于
2017-07-01 16:23 被阅读35次NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
WKUserContentController *wkUController = [[WKUserContentController alloc] init];
WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
[wkUController addUserScript:wkUScript];
WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
wkWebConfig.userContentController = wkUController;
self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:wkWebConfig];
[self.view addSubview:self.webView];
NSString *pathStr = [[NSBundle mainBundle] pathForResource:@"storage" ofType:@"html"];
NSURL *fileURL = [NSURL fileURLWithPath:pathStr];
[self.webView loadFileURL:fileURL allowingReadAccessToURL:fileURL];
本文标题:WKWebView自适应大小
本文链接:https://www.haomeiwen.com/subject/qlqgcxtx.html
网友评论