UIWebView's ability to execute Javascript is independent of whether a page has loaded or not. Its possible use stringByEvaluatingJavaScriptFromString: to execute Javascript before you have even made a call to load a page in UIWebView in the first place, or without loading a page at all.
Therefore I cannot understand how the answer in this link is accepted: webViewDidFinishLoad: Firing too soon?
because calling any Javascript doesn't tell you anything at all (if they are calling some interesting Javascript, which is monitoring the dom for example, they don't make any mention of that and if there were they would because its important).
You could call some Javascript that, for example, examines the state of the dom or the state of the loaded page, and reports that back to the calling code however if it reports that the page has not loaded yet then what do you do? - you'll have to call it again a bit later, but how much later, when, where, how, how often, ....
Polling is usually never a nice solution for anything.
The only way to know when the page has totally loaded and be accurate and in control of knowing exactly what what its in is to do it yourself - attach JavaScript event listeners into the page being loaded and get them to call your shouldStartLoadWithRequest: with some proprietary url. You could, for example, create a JS function to listen for a window load or dom ready event etc. depending upon if you need to know when the page has loaded, or if just the dom had loaded etc. Depending upon your needs.
If the web page is not your's then you can put this javascript into a file and inject it into every page you load.
How to create the javascript event listeners is standard javascript, nothing specially to do with iOS, for example here is the JavaScript to detect when the dom has loaded in a form that can be injected into the loading page from within the UIWebView and then result in a call to shouldStartLoadWithRequest: (this would invoke shouldStartLoadWithRequestwhen: the dom has finished loadeding, which is before the full page content has been displayed, to detect this just change the event listener).
var script = document.createElement('script');
script.type = 'text/javascript';
script.text = function DOMReady() {
document.location.href = "mydomain://DOMIsReady";
}
function addScript()
{
document.getElementsByTagName('head')[0].appendChild(script);
document.addEventListener('DOMContentLoaded', DOMReady, false);
}
addScript();