lazy var webView:WKWebView = {
/*
NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
WKUserContentController *wkUController = [[WKUserContentController alloc] init];
[wkUController addUserScript:wkUScript];
WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
wkWebConfig.userContentController = wkUController;
_myWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(headerView.frame)+10, M_S.width,M_S.height - CGRectGetMaxY(headerView.frame) - 40) configuration:wkWebConfig];
*/
let js = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta)";
let configuration = WKWebViewConfiguration()
let userScript = WKUserScript(source: js, injectionTime: .atDocumentEnd, forMainFrameOnly: true)
let wkUController = WKUserContentController()
wkUController.addUserScript(userScript)
configuration.userContentController = wkUController;
let wkView = WKWebView(frame: CGRect(x: 0.0, y: 64.0, width: swidth, height: sheight-64), configuration: configuration)
wkView.navigationDelegate = self
wkView.scrollView.delegate = self;
return wkView;
}()

  参考:http://stackoverflow.com/questions/26295277/wkwebview-equivalent-for-uiwebviews-scalespagetofit

最新文章

  1. CSS3——transform学习
  2. javaccript学习1
  3. 自定义getElementByClass
  4. best matched pair
  5. CLR的执行模型
  6. JavaWeb学习记录(七)——MVC操作数据库增删改查与分页功能
  7. [置顶] Hibernate的一个经典异常
  8. d029: 求出2-100之间的所有质数(素数)
  9. 添加jar
  10. c# 用正则表达式在指定的字符串中每隔指定个数的文字插入指定字符串
  11. django中使用Model的update_or_create函数时报错
  12. Docker 集群
  13. MQ & RPC 消息队列与RPC的区别与使用场景
  14. python3中list列表的一些操作
  15. python的几个小程序
  16. Simultaneous Localization and Mapping Technology Based on Project Tango
  17. 使用chrome控制台作为日志查看器
  18. uva10003
  19. POJ 2462 / HDU 1154 Cutting a Polygon
  20. Redis学习---Redis操作之Python连接

热门文章

  1. Java中关键字static的使用
  2. lodash 中常用的方法
  3. python 日志滚动 分文件
  4. log4j日志整合输出(slf4j+commonslog+log4j+jdklogger)
  5. oracl之导入dmp文件
  6. 别人的Linux私房菜(2)Linux简介
  7. 51.从首页内容跳转到第二个Tabbar控制器(controller)
  8. ios 数组和字典
  9. 2019.01.16 bzoj4399: 魔法少女LJJ(线段树合并)
  10. 2018.11.02 NOIP模拟 优美的序列(数论+单调栈/链表)