IOS系统中网络等待的Loading的实现方法的代码

在写内容过程中,把写内容过程中比较好的内容珍藏起来,下边内容内容是关于IOS系统中网络等待的Loading的实现方法的内容,希望能对码农有所帮助。


WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)];
[WebView setUserInteractionEnabled:NO];
[WebView setBackgroundColor:[UIColor clearColor]];
[WebView setDelegate:self];

[WebView loadRequest:[NSURLRequest requestWithURL:url]];

[view setTag:103];
[view setBackgroundColor:[UIColor blackColor]];
[view setAlpha:0.8];
[self.view addSubview:view];

activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
[activityIndicator setCenter:view.center];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[view addSubview:activityIndicator];
[self.view addSubview:WebView];
[view release];
[WebView release];

      [activityIndicator startAnimating];         
}

     [activityIndicator stopAnimating];    
     [view removeFromSuperview];
}

第二种方法:使用UIAlertViewandUIActivityIndicatorView


    if (myAlert==nil){        
       myAlert = [[UIAlertView alloc] initWithTitle:nil 
                          message: @"读取中..."
                            delegate: self
             cancelButtonTitle: nil
             otherButtonTitles: nil];

     activityView.frame = CGRectMake(120.f, 48.0f, 38.0f, 38.0f);
     [myAlert addSubview:activityView];
     [activityView startAnimating];
     [myAlert show];
     }
}

      [myAlert dismissWithClickedButtonIndex:0 animated:YES];
}