Wkwebview Progress and Title
Wkwebview's estimatedprogress and title are KVO modes, so you can add monitoring:
[webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL]; [webView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
How to implement monitoring:
- (void) Observevalueforkeypath: (NSString *) KeyPath Ofobject: (ID)ObjectChange: (nsdictionary *) Change context: (void*) Context {if([KeyPath isequaltostring:@"estimatedprogress"]) { if(Object==WebView) {[Self.progressview Setalpha:1.0f]; [Self.progressview setProgress:self.currentSubView.webView.estimatedProgress Animated:yes]; if(Self.currentSubView.webView.estimatedProgress >=1.0f) {[UIView animatewithduration:0.3Delay0.3Options:uiviewanimationoptioncurveeaseout animations:^{[Self.progressview setalpha:0.0f]; } Completion:^(BOOL finished) {[Self.progressview setprogress:0.0fAnimated:no]; }]; } } Else{[Super Observevalueforkeypath:keypath Ofobject:ObjectChange:change Context:context]; } } Else if([KeyPath isequaltostring:@"title"]) { if(Object==self.webview) {self.title=Self.webView.title; } Else{[Super Observevalueforkeypath:keypath Ofobject:ObjectChange:change Context:context]; } } Else{[Super Observevalueforkeypath:keypath Ofobject:ObjectChange:change Context:context]; }}
The progress here is animated, like Safari's progress effect
It's important to note that when destroying, you must remove the monitoring
[WebView removeobserver:self Forkeypath:@ "estimatedprogress"]; [WebView removeobserver:self Forkeypath: @" title "];
Wkwebview Progress and Title