UIWebView VS WKWebView加载本地html [英] UIWebView VS WKWebView to load local html

查看:214
本文介绍了UIWebView VS WKWebView加载本地html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有时间戳的500 p标签的html字符串

i create a html string with 500 p tag with timestamp in it

我使用UIWebViewWKWebView loadHTMLString:baseURL:进行加载,而wkWebView的速度比UIWebVIew 50%.为什么?

i use UIWebView and WKWebView loadHTMLString:baseURL: to load it,and wkWebView is slower about 50% than UIWebVIew. why?

UIWebView:0.1681529879570007
WKWebView:0.3913570046424866

推荐答案

WKWebView可以更快地显示来自字符串的html.但是,默认情况下,有一个错误可使UIWebView更快,这是电话号码检测.

WKWebView is faster for displaying html from Strings. However, there is a bug that makes UIWebView faster by default, which is the phone number detection.

使用以下代码运行一个viewController,webView分别是一个UIWebView和WKWebView实例,并使其他所有东西保持相同,我发现WKWebView最多需要2秒钟加载,而UIWebView几乎立即加载.

Running a viewController with the following code, webView being respectively a UIWebView and WKWebView instance and keeping everything else identical I found WKWebView to take up to 2 seconds to load, while UIWebView loads almost instantly.

webView.loadHTMLString(HtmlStringInstance, baseURL: nil)

到目前为止,我并不是唯一一个找到这个的人:

I'm by far not the only one to find this:

  • when I use wkwebview to load local html,I find it renders slower than uiwebview
  • UIWebView delay in loading local content
  • Slow loading UIWebView from string
  • Delay in loading a HTML string into a UIWebView
  • Why UIWebView work so slowly when loadHTMLString with UIWebView?

但是,解决方案很简单:禁用WKWebView和poof的电话号码检测.你去那里.

However, the solution is easy: Disable phone number detection for WKWebView and poof. There you go.

这篇关于UIWebView VS WKWebView加载本地html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆