In my webViewDidFinishLoad method, I have the following code:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
if (hasPressed == 1) {
hasPressed = 0;
isBlocked = 0;
}
else if (hasPressed == 0 && hasDroppedDown == 0) {
if (viewState != kStateWeather || isBlocked == 0) {
[UIView animateWithDuration:0.5
delay:0.0 options:UIViewAnimationCurveLinear animations:^{
//Animations
}
completion:^(BOOL finished){
hasDroppedDown = 1;
}];
}
}
}
As you can see, if this method is called rapidly, e.g. a website that has a redirect, the else in my else if becomes useless. How do I stop it from being called so rapidly?
Unfortunately, you cant do that. It will call when ever a new URL is start loading in the
UIWebView. Instead you can do one thing.Implement the delegate function
This delegate will be called when a new frame is about to start loading in the
UIWebView.You can figure out which type of request is going to load by checking the
navigationTypewhich can attain valuesNote: return
YESif you allow the webview to load the page elseNO.Hope this help you.