我希望在加载完整网页之前显示我的活动指示器。请帮助我提供一些示例程序或博客。谢谢
webView = [[UIWebView alloc] initWithFrame:webFrame];
webView.backgroundColor = [UIColor greenColor];
[second.view addSubview:webView];
webView.backgroundColor = [UIColor grayColor];
webView.scalesPageToFit=YES;
[webView release];
NSString *urlAddress = storyLink;
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView startAnimating];
我在里面使用了上面的代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {}
方法。
我用以下方法创建了活动指示器
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[super viewWillAppear:YES];
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
[self navigationItem].rightBarButtonItem = barButton;
}
对我来说,活动指示符会在 3 秒内创建和销毁。我希望它一直显示到网页完全加载。请帮帮我。谢谢。