隐藏网络活动指标

时间:2010-04-09 20:15:20

标签: iphone objective-c cocoa-touch xcode

- (void)viewWillAppear:(BOOL)animated {
   app = [UIApplication sharedApplication];
   app.networkActivityIndicatorVisible = YES; 
   NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
   NSURLRequest *request = [NSURLRequest requestWithURL:url];
   [webView loadRequest:request];
}

-(void)webViewDidFinishLoad {
   app.networkActivityIndicatorVisible = NO;
}

我希望在加载网页后隐藏网络活动指示符。我写了上面的代码。但是在网页完全加载后,指标并未隐藏。

任何人都请帮忙。

1 个答案:

答案 0 :(得分:1)

(1)该方法应称为- (void)webViewDidFinishLoad:(UIWebView *)webView。论证必须出现。

- (void)webViewDidFinishLoad:(UIWebView *)webView { 
    app.networkActivityIndicatorVisible = NO;
}

(2)确保将self设置为Web视图的委托。