UIWebView VS WKWebView加载本地html [英] UIWebView VS WKWebView to load local html
问题描述
我创建了一个带有时间戳的500 p标签的html字符串
i create a html string with 500 p tag with timestamp in it
我使用UIWebView
和WKWebView 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:
- 当我使用wkwebview加载本地html时,我发现它的渲染速度比uiwebview慢
- UIWebView延迟加载本地内容
- 从字符串中缓慢加载UIWebView
- 延迟将HTML字符串加载到UIWebView中
- 为什么当使用UIWebView加载HTMLString时,UIWebView的工作如此缓慢? /a>
- 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屋!