3

I'm starting to use RxSwift at work and I'm on a project right now where I need to capture clicked links in a web view. But I can’t get this method :
webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
from the UIWebViewDelegate to work. It's never called no matter what I do.

I tried to use the DelegateProxy thing but I think I don’t get it...
I’m also trying to figure out what would be a more “Reactive” way to do this.

Nicolas
  • 31
  • 3

2 Answers2

1

If you're using some of the Reactive Properties, your delegate is already "taken over" by RxSwift/RxCocoa. If you want to use your delegate "as usual" alongside RxSwift you'll need to set a the delegate proxy.

e.g.

webView.rx.setDelegate(self).disposed(by: disposeBag)
Shai Mishali
  • 9,224
  • 4
  • 56
  • 83
0

I found out what was wrong: it was my implementation of the method that returned false when it was first called by the web view... I just didn't knew that it was called when calling programmatically...

Nicolas
  • 31
  • 3