开发者

How would I declare this function?

开发者_JAVA百科

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:
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜