Understanding of UIWebView and WKWebview

tags: H5+app development  UIWebView  WKWebView  5+app  IOS

iOS has two webviews: UIWebview and WKWebview. Starting from iOS13, Apple has listed UIWebview as an expired API.The App Store will no longer accept new apps that use UIWebView from April 2020, and will no longer accept app updates that use UIWebView from December 2020.

In the development of 5+app, since HBuilderX 2.2.5, the default on iOS has been WKWebview. Unless the developer manually specifies in the code to use UIWebview, the actual rendered pages are rendered in WKWebview. However, although the actual page is rendered by WKWebview, there is still an optional reference to UIWebview in the source code of the App underlying engine. Appstore's computer review will find that the binary code includes a reference to UIWebview, which will cause an alarm.
Starting from HBuilderX 2.6.6, uiWebview has been removed from the basic engine and turned into an optional module (selected in the manifest), and the machine review is not prompted.

Now let's explain the difference between UIwebview and WKwebview and their differences.

UIwebview

UIWebView is used to embed web content in the App, usually in html format, and also supports pdf, word and other documents.

Control advantages

  1. Cross-platform
       It can deploy iOS, Android and other platforms once developed.

  2. Fast release and update
       is released on the server side, which can update the terminal display in real time, which is convenient for quick upgrades and emergency bug fixes.

  3. Strong layout ability
      The powerful HTML+CSS makes people worship

Control disadvantages

  1. performance
       One of Native’s favorite sayings when arguing with HTML5 is: "Your performance is not good." Web App runs in the browser, and the open capability of the browser is difficult to support HTML5 and Native confrontation.

  2. Complex data communication
       Data communication between UIWebView and App can only be done through javascript or UIWebViewDelegate. It is more complicated for the client to pass parameters to UIWebView to modify the webpage or obtain data from the webpage.

scenes to be used

  1. Typesetting complex content

  2. Interface that needs flexible control in the background

  3. Original page

WKWebview

With the application of IOS development,More and more web embedding, Before IOS 8, we used UIWebView to display the detail page. Since IOS 8, WKWebView has appeared. Compared with UIWebView, WKWebView has optimized more experience.

Advantages of WKWebView

WKWebView uses a cross-process solution, Nitro JS parser, and a refresh rate of up to 60fps. The theoretical performance is comparable to that of Safari, and it also has high support for H5.

1. The memory overhead of WKWebView is much smaller than UIWebView

2. Built-in gestures

3. Supports more HTML5 features

4. Have the same JavaScript engine as Safari

5. Provide commonly used attributes, such as estimatedProgress attribute of loading webpage progress

The difference between the two

UIWebview has existed since iOS2, and WKWebView has only existed since iOS8. There is no doubt that WKWebView will gradually replace the bulky UIWebview. Through the official performance test, it can be found that UIWebview takes up too much memory, and the peak memory is even more exaggerated. WKWebView web page loading speed has also improved, but not as much as memory.

WKWebView is a new H5 container used by Apple when it announced WebKit when it announced IOS8 at the WWDC2014 conference. Compared with UIWebView, it has faster loading speed and performance, and lower memory usage. Refactored UIWebViewDelegate and UIWebView into 14 classes and 3 protocols, allowing developers to perform more detailed configuration.

But his most fatal flaw is that the request of WKWebView cannot be intercepted by NSURLProtocol.

The above figure shows the flow of UIWebview and WKWebView. The granularity of WKWebView is more detailed. Not only will WKWebView be asked whether to request data when requesting, but also WKWebView will be asked whether to load data after returning the data.

For more information about how to use UIwebview and WKwebview, please visitTutorial link。

 

Intelligent Recommendation

Replace UIWebView with WKWebView

In the process of developing an app, you often encounter loading web pages inside the app, usuallyUIWebViewload. This webpage loader, which has been used since iOS2, has been developed.Heart disease: ...

UIWebView and WKWebView set cookies

UIWebView settings cookie InwebViewDidFinishLoadGet the cookie and pass itNSUserDefaultssave 2. Add a cookie that has been saved locally before requesting the network. WKWebVIew set cookie 1. Get a co...

UIWebView & WKWebView detailed on

Foreword Always wanted to summarize the systemUIWebViewwithWKWebViewHere is a sort of one DemoFor reference Divided into two parts: UIWebView & WKWebView Under UIWebView & WKWebView OC-->JS...

WKWebView instead of UIWebVIew

WKWebView from entry to squat UIWebView is available from iOS2. After iOS8, Apple introduced a new framework, WebKit, which provides a component to replace UIWebView, WKWebView. WKWebView performance ...

Tucao UIWebView and WKWebview

Another year is 3.15, Apple's father disabled JSPatch a few days ago, so I won't spit it out. Here are two WebViews - UIWebView and WKWebview on iOS. UIWebView birth defects It is said that in the pas...

More Recommendation

[Reserved] iOS UIWebView and WKWebView

This article is reproduced,Original address One,Overview UIWebView is available from iOS2, WKWebView is only available from iOS8, and there is no doubt that WKWebView will gradually replace the bulky ...

WKWebView, UIWebView set localStorage

WKWebView set localStorage UIWebView set localStorage...

UIWebView and WKWebView in iOS

1. UIWebView UIWebView for system versions below iOS 8.0 iOS native does not provide a way to directly call OC by js. It can only be intercepted by UIWebViewDelegate protocol method of UIWebView, and ...

JS and UIWebview and WKWebView interaction

I have recently done several hybrid applications, and some of the JS and Webview interaction experiences are summarized: Read a lot of big framework source, whether it iscordovastill isWebViewJavascri...

WKWebView replaces UIWebView

1. Introduce header files 2. First use WKWebView basic method to write an example, load baidu page, similar to UIWebView Using the same method, I also wrote a page with UIWebView to compare and found ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top