1、KVO,可监听标题、加载进度、网络地址
//1 添加KVO
[webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];//进度
[webView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];//标题
[webView addObserver:self forKeyPath:@"URL" options:NSKeyValueObservingOptionNew context:NULL];//网址
//2 实现
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"estimatedProgress"]) {
//加载进度值
//webView.estimatedProgress
}else if ([keyPath isEqualToString:@"title"]) {
//网页title
//webView.title
}else if ([keyPath isEqualToString:@"URL"]) {
//网页地址
NSString *urlString = self.webView.URL.absoluteString;
NSURL *url = [NSURL URLWithString:urlString];
}
}else {