Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在多个webview中停止多个活动指示器动画?_Iphone_Ipad_Uiwebview_Uiactivityindicatorview - Fatal编程技术网

Iphone 如何在多个webview中停止多个活动指示器动画?

Iphone 如何在多个webview中停止多个活动指示器动画?,iphone,ipad,uiwebview,uiactivityindicatorview,Iphone,Ipad,Uiwebview,Uiactivityindicatorview,目前,我正在开发一个示例,其中我在ipad屏幕上显示了4个webview,并试图在其中显示4个不同的URL 所有网页都完美地显示在webview中 当网页开始加载时,我还会显示4个活动指示器 但我不知道如何停止活动指标,在所有相应的网页一个接一个,一旦他们加载到屏幕上 -(void)createWebView { //******************** First ********* firstWebView=[[UIWebView alloc]init]; f

目前,我正在开发一个示例,其中我在ipad屏幕上显示了4个webview,并试图在其中显示4个不同的URL

所有网页都完美地显示在webview中

当网页开始加载时,我还会显示4个活动指示器

但我不知道如何停止活动指标,在所有相应的网页一个接一个,一旦他们加载到屏幕上

-(void)createWebView
{

    //******************** First *********

    firstWebView=[[UIWebView alloc]init];
    firstWebView.frame=CGRectMake(10, 50, 350, 470);
    firstWebView.delegate=self;
    firstIndicator = [[UIActivityIndicatorView alloc] 
                                        initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    firstIndicator.center = CGPointMake(160, 240);
    firstIndicator.hidesWhenStopped = YES;
    [self.firstWebView addSubview:firstIndicator];
    [firstIndicator startAnimating];
    firstWebView.backgroundColor=[UIColor grayColor];
     NSURL *firstUrl = [NSURL URLWithString:@"http://www.techtree.com"];
     NSURLRequest *firstRequestObj = [NSURLRequest requestWithURL:firstUrl];
    [firstWebView loadRequest:firstRequestObj];
    [self.view addSubview:firstWebView]; 

    //******************* Second *********

    secondWebView=[[UIWebView alloc]init];
    secondWebView.frame=CGRectMake(405, 50, 350, 470);
    secondWebView.delegate=self;

    secondIndicator = [[UIActivityIndicatorView alloc] 
                      initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    secondIndicator.center = CGPointMake(160, 240);
    secondIndicator.hidesWhenStopped = YES;
    [self.secondWebView addSubview:secondIndicator];
    [secondIndicator startAnimating];
    secondWebView.backgroundColor=[UIColor grayColor];

    NSURL *secondUrl = [NSURL URLWithString:@"http://www.facebook.com"];
    NSURLRequest *secondRequestObj = [NSURLRequest requestWithURL:secondUrl];
    [secondWebView loadRequest:secondRequestObj];
    [self.view addSubview:secondWebView]; 


    //****************** Third ************

    thirdWebView=[[UIWebView alloc] init];
    thirdWebView.frame=CGRectMake(10, 528, 350, 470);
    thirdWebView.delegate=self;


    thirdIndicator = [[UIActivityIndicatorView alloc] 
                       initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    thirdIndicator.center = CGPointMake(160, 240);
    thirdIndicator.hidesWhenStopped = YES;
    [self.thirdWebView addSubview:thirdIndicator];
    [thirdIndicator startAnimating];

    thirdWebView.backgroundColor=[UIColor grayColor];

    NSURL *thirdUrl = [NSURL URLWithString:@"http://www.yahoo.com"];
    NSURLRequest *thirdRequestObj = [NSURLRequest requestWithURL:thirdUrl];
    [thirdWebView loadRequest:thirdRequestObj];
    [self.view addSubview:thirdWebView];

    //***************** Fourth ************
    fourthWebView=[[UIWebView alloc] init];
    fourthWebView.frame=CGRectMake(405,528, 350, 470);
    fourthWebView.delegate=self;


    fourthIndicator = [[UIActivityIndicatorView alloc] 
                      initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    fourthIndicator.center = CGPointMake(160, 240);
    fourthIndicator.hidesWhenStopped = YES;
    [self.fourthWebView addSubview:fourthIndicator];
    [fourthIndicator startAnimating];

    fourthWebView.backgroundColor=[UIColor grayColor];

    NSURL *fourthUrl = [NSURL URLWithString:@"http://stackoverflow.com"];
    NSURLRequest *fourthRequestObj = [NSURLRequest requestWithURL:fourthUrl];
    [fourthWebView loadRequest:fourthRequestObj];
    [self.view addSubview:fourthWebView];


    //******************** Memory Managemt **********
    [firstWebView release];
    [secondWebView release];
    [thirdWebView release];
    [fourthWebView release];

    [firstIndicator release];
    [secondIndicator release];
    [thirdIndicator release];
    [fourthIndicator release];


}

感谢它的工作。还有一个问题,我如何才能使它更快,因为它花费了太多的时间来加载所有的网页。
overwrite below delegate method and check which webview is loading finished like below

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
   if(webView== firstWebView)
   { 
     [firstIndicator setHidden:YES];
   }
  else
  {
     so on...
  }
}