Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
689 views
in Technique[技术] by (71.8m points)

ios - UIWebView VS WKWebView to load local html

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

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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:

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...