// 桥接
self.bridge = [WebViewJavascriptBridge bridgeForWebView:self.webview];
[self.bridge setWebViewDelegate:self];
[self _addWebBridge];
// 进度
_progressProxy = [[NJKWebViewProgress alloc] init];
_progressProxy.webViewProxyDelegate = self;// 这个地方导致上面设置 [self.bridge setWebViewDelegate:self]; 失效了。
_progressProxy.progressDelegate = self;
self.webview.delegate = _progressProxy;
CGFloat progressBarHeight = 3.f;
CGRect barFrame = CGRectMake(0,0, [UIScreen mainScreen].bounds.size.width, progressBarHeight);
_progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview:_progressView]
为什么是导致失效呢,因为代理是weak类型,是一对一的。
解决方案
1._progressProxy.webViewProxyDelegate = self.bridge;
2.http://codecloud.net/17404.html