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