0

I know that there are delegate methods. In my case, the scenario is little bit different. When I load my request, there are subsequent calls that happens. So the page get loaded back to back with 3 urls. After that, it stops.

When it is done loading everything, after that actually I wanted to do something like 'autosubmit', which is not possible for mobile browsers. I am looking for a work around. But for that too, I need to make sure that the webView has done loading.

So my question here is, is there any proper way to find out that the web view has finally stopped loading, and then I can try something to do my 'autosubmit' part?

Vaibhav Tekam
  • 2,344
  • 3
  • 18
  • 27
  • Possible duplicate of [UIWebView didFinishLoading fires multiple times](http://stackoverflow.com/questions/1842370/uiwebview-didfinishloading-fires-multiple-times)? – mAu Aug 02 '12 at 07:19
  • 1
    tried whats suggested there, not much of help, I see the webView.loading variable holds same value throughout the calls. – Vaibhav Tekam Aug 02 '12 at 09:18
  • @VaibhavTekam is right. Unfortunately the UIWebView delegate methods are very unreliable. – Stunner Aug 02 '12 at 10:31

1 Answers1

0

I have an answer to the detecting when the web view is done loading part of your question... Unfortunately, the most reliable method I have found is to increment a counter whenever webViewDidBeginLoad: is called and decrementing it whenever webViewDidFinishLoading: and webViewDidFailWithError: is called. Whenever the counter is equal to 0 you know that the web view is not loading.

Placing this check in the webViewDidFinishLoading: and webViewDidFailWithError: methods will allow you to determine when the web has completed or stopped loading (in the case of a failure).

Stunner
  • 12,025
  • 12
  • 86
  • 145
  • In webViewDidStartLoad: I will increase the count which will be 1 for the first time. Then webViewDidFinishLoading will get called and I will decrease it. Now it will be 0. But soon after that, my page will again get loaded, due to redirection or ajax calls. So, this approach won't help. – Vaibhav Tekam Aug 02 '12 at 09:24
  • Try decreasing after a certain delay (e.g. 0.5s). If there was made any request in the meantime, your counter still holds a value > 0. – mAu Aug 02 '12 at 10:19