How would I declare this function?
I'm needing help with this answer from UIWebView - How to identify the "last" webViewDidFinishLoad message?
How would I declare webViewLoads_++; and webViewLoads_--; in the following code:
- (void)webViewDidStartLoad:(UIWebView *)webView {
webViewLoads_++;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
webViewLoads_--;
if (webViewLoads_ > 0) {
return;
}
…
}
Thanks
Should be in instance variable of type int: int webViewLoads_;
in the .h file.
The simplest way is to declare an int
in your .m (implementation) file, above webViewDidStartLoad:
:
int webViewLoads_ = 0;
Remember to reset this to 0 when the last load completes:
webViewLoads_--;
if (webViewLoads_ > 0)
{
return;
}
webViewLoads_ = 0;
You can tell when a webview is really "done" by using the delegate method:
webView:didFinishLoadForFrame:
精彩评论