thomax thomax - 2 months ago 55x
iOS Question

UIWebViewDelegate: webViewDidFinishLoad not called during in-page navigation

I have an app where users can navigate a pile of locally stored HTML files. I have a

, configured up correctly with a
. Usually, when the user follows a link,
is called, followed by
a bit later.

But, if the link is pointing to an anchor on the same page as the one which is currently displayed, only
is called.
does not fire.

In a sense, I see that this might be expected behaviour, because in-page navigation should not require a page reload. However, I really need a place to hook into the call stack after in-page navigation is complete. The optimal solution would let me know when any sort of navigation has ended, both from another page, in-page and forward/backward actions.

My best hackaround so far has been to call
performSelector: withObject: afterDelay:
at the end of my
method, but I'm not happy with this.

Does anyone know how I can solve this correctly? Any insight appreciated!


You can try to use NSURLConnectionDataDelegate, it allows you to handle incoming data. Maybe you can determine if the page is loaded manually by adding a sign to your html files.

NSURLConnectionDataDelegate Reference

Edit: I wrote a piece of code and it worked, that may not be the way you wanted it to work but maybe it helps. Every time user clicks a URL with anchor, it creates another connection and as connection finishes loading web view loads the data, that marks the point where web view finished loading the page. As you use only local html files, I do not think creating connections will create problems