In my webView
's delegate method I am checking for the condition when webview
loading fully completes by using this code:
if ([[webView stringByEvaluatingJavaScriptFromString:@"document.readyState"] isEqualToString:@"complete"]) {
//Code to handle other things
//Sometimes after this block shouldStartLoadWithRequest is called
}
Sometimes even control goes to if block even then -shouldStartLoadWithRequest
this method is being called and my code breaks.
Is their any other alternative? I also tried webview.isLoading
but this also doesn't work.
I have found one workaround to stop any further execution of scripts after didFinishLoading.
I used following condition to stop reqeust:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType
{
if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
//my code
}
}