The--wkwebview of IOS8 WebKit Library

Source: Internet
Author: User

Apple and Google have made an important contribution to the WebKit of the browser engine, and in WWDC 2014 launch, Apple unveiled the WebKit framework, which means that OSX and iOS developers will share the same development library, New changes can improve the reuse of code written by developers.
WebKit uses Wkwebview instead of iOS UIWebView and OSX WebView, and uses the Nitro JavaScript engine, which means that all third-party browsers run JavaScript as fast as Safari.
First, Wkwebview added properties and methods
Analogy UIWebView, compared with UIWebView's API,
Added properties:
1, estimatedprogress loading progress bar, before IOS8 we are through a fake progress bar to achieve
2, Backforwardlist said Historylist
3, Wkwebviewconfiguration *configuration; Initialize the configuration of the WebView
Added method:
1,-(Instancetype) initWithFrame: (CGRect) frame configuration: (Wkwebviewconfiguration *) configuration
Initialization
3, (Wknavigation *) Gotobackforwardlistitem: (Wkbackforwardlistitem *) item;
Jump to a page of history
Second, the same properties and methods
GoBack, GoForward, CanGoBack, CanGoForward, stoploading, Loadrequest, ScrollView
Third, the deleted properties and methods:
1,-(NSString *) stringbyevaluatingjavascriptfromstring: (NSString *) script;
When interacting with JS, we use this API, and currently Wkwebview does not give the API to implement similar functions.
2. Unable to set cache
In UIWebView, using the Nsurlcache cache, the Setsharedurlcache can be set to our own cache, but Wkwebview does not support Nsurlcache
Iv. differences in Delegate methods
UIWebView supported agents are Uiwebviewdelegate,wkwebview supported proxies are wknavigationdelegate and wkuidelegate
Wknavigationdelegate mainly implements the callback method which involves the navigation jump aspect.
Wkuidelegate mainly implements the callback method involving the interface display, such as the change of Wkwebview and JS related content.
Specifically, Wknavigationdelegate has an additional three proxy methods in addition to the APIs that start loading, loading successfully, and failing to load:
1,-(void) WebView: (Wkwebview *) WebView didreceiveserverredirectforprovisionalnavigation: (wknavigation *) navigation
This agent is called when the server redirect
2,-(void) WebView: (Wkwebview *) WebView decidepolicyfornavigationresponse: (Wknavigationresponse *) Navigationresponse Decisionhandler: (void (^) (wknavigationresponsepolicy)) Decisionhandler
This proxy method indicates that when the client receives the server's response header, depending on the response information, it can decide whether the jump can continue.
3.-(void) WebView: (Wkwebview *) WebView decidepolicyfornavigationaction: (wknavigationaction *) navigationaction Decisionhandler: (void (^) (wknavigationactionpolicy)) Decisionhandler
According to WebView, navigationaction related information determines whether this jump can continue, this information contains HTTP send request, such as header contains User-agent,accept

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.