3

I'm trying to cache specified web pages to disk by NSURLProtocol,now I can only get the first URL request, but the UIWebView spawns further URL requests for loading graphics. So how can I Intercept all the requests spawned by UIWebView from the first URL? Thank you very much!

Suge
  • 2,808
  • 3
  • 48
  • 79

1 Answers1

4

Implement delegate method

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;

every time your webview loads url it will first call this method.

Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
  • 3
    Thank you ,but I found the shouldStartLoadWithRequest catch only first request of the UIWebView, the other requests such as image requests, js requests do not call this function. – Suge Apr 11 '13 at 12:06