Wkwebview is the new web browsing view of IOS8
Advantage : Loading speed is almost one times higher than UIWebView, memory use above, but less half.
Disadvantages : Wkwebview does not support caching and Nsurlprotocol interception.
I recommend that if you use a page that is not high on the cache, the user experience will improve a lot.
Since the project was previously UIWebView and compatible with IOS8 before. So I created a new class Imywebview you can seamlessly upgrade to Wkwebview if you replace UIWebView globally.
The APIs in IMYWebView.h automatically support UIWebView and Wkwebview internally,
title,estimatedprogress is the new API that I think is more useful in Wkwebview
@interface imyvkwebview:uiview///using uiwebview-(instancetype) initWithFrame: (CGRect) frame Usinguiwebview: (BOOL) Usinguiwebview; @property (weak,nonatomic) id<imyvkwebviewdelegate> delegate;///Internal Use Webview@property ( Nonatomic, ReadOnly) ID realwebview;///Whether you are using Uiwebview@property (nonatomic, readonly) BOOL usinguiwebview;/// Estimated page Load Progress @property (Nonatomic, readonly) double estimatedprogress; @property (nonatomic, readonly) nsurlrequest * Originrequest;///back Layer-(Nsinteger) countofhistory;-(void) Gobackwithstep: (nsinteger) step;///----UI or WK Api@property (nonatomic, ReadOnly) Uiscrollview *scrollview;-(ID) loadrequest: (Nsurlrequest *) request;-(ID) loadHTMLString: (NSString *) string BaseURL: (Nsurl *) BaseURL; @property (nonatomic, readonly, copy) NSString *title;@ Property (Nonatomic, ReadOnly) nsurlrequest *currentrequest; @property (nonatomic, readonly) Nsurl *url; @property ( Nonatomic, ReadOnly, getter=isloading) bool loading; @property (nonatomic, readonly) bool CanGoBack; @property (nonatomIC, ReadOnly) BOOL cangoforward;-(ID) goback;-(ID) goforward;-(ID) reload;-(ID) reloadfromorigin;-(void) stoploading;- (void) Evaluatejavascript: (NSString *) javascriptstring Completionhandler: (void (^) (ID, Nserror *)) Completionhandler //////Do not recommend this method because it will wait for the WebView execution result internally-(NSString *) stringbyevaluatingjavascriptfromstring: (NSString *) Javascriptstring __deprecated_msg ("Method deprecated. Use [Evaluatejavascript:completionhandler:] ");/////whether to scale the page according to the view size default is Yes@property (nonatomic) BOOL scalespagetofit;@ End
Code address
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
UIWebView Seamless Switch to Wkwebview