Apple and Google have made an important contribution to the WebKit of the browser engine. Released at the WWDC 2014 release of iOS 8, Apple unveiled the WebKit framework, which means that OSX and iOS developers will share the same development library. The new changes can improve the reuse of code written by developers.
WebKit uses Wkwebview to replace the iOS UIWebView and OSX WebView, and uses the Nitro JavaScript engine, which means that all third-party browsers will execute JavaScript as fast as Safari.
First, Wkwebview added properties and methods
Analogy UIWebView, compared with UIWebView's API.
Properties added:
1, estimatedprogress loading progress bar. Before IOS8, we realized it through a fake progress bar.
2, Backforwardlist said Historylist
3, Wkwebviewconfiguration *configuration; Initialize the configuration of the WebView
Add the 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 now 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.
In detail, wknavigationdelegate except for APIs that start loading, loading successfully, and loading failures. There are additional three proxy methods:
1,-(void) WebView: (Wkwebview *) WebView didreceiveserverredirectforprovisionalnavigation: (wknavigation *) navigation
This agent is serverredirect when called
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, according to the response information, it can decide whether the jump will be enough to 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 includes HTTP send requests, such as the head including user-agent,accept
The--wkwebview of IOS8 WebKit Library