UIWebView에서 UIACtivityIndicatorView 사용

2869 단어 UIWebView
            
 UIWebView       ,      UIActivityIndicatorView    UIWebview     ,       
        ,          UIWebview        view(opaqueview)        ,    
UIActivityIndicatorView          view(opaqueview) 。                
UIActivityIndicatorView  ,                UIActivityIndicatorView,       
UIWebView     。

 .UIWebView            

1.loadRequest:

2.loadHTMLString:string baseURL:

3.loadData:MIMEType:textEncodingName:baseURL:

  baseURL      url         ,                                     ;

 .UIWebView        
1.- (void )webViewDidStartLoad:(UIWebView
*)webView              

2.- (void )webViewDidFinishLoad:(UIWebView
*)webView             

3.-(BOOL )webView:(UIWebView *)webView 
shouldStartLoadWithRequest:(NSURLRequest *)request 
navigationType:(UIWebViewNavigationType )navigationType

    UIWebView    1               ,    webViewDidStartLoad  ,                   ,URL       。

4.- (void)webView:(UIWebView *)webView
didFailLoadWithError:(NSError *)error

        ,                             

 .    

1. .h       UIWebviewDelegate  

  WebView

2.  UIWebView

WebView = [[UIWebView
alloc] initWithFrame: CGRectMake(x,x,x,x)];

[WebView
setUserInteractionEnabled:YES]; 
//      

[WebView setDelegate:self]; //  

[WebView setOpaque:NO]; //  

[self. viewaddSubview: WebView]; //      view



url= [[NSURLalloc]initWithString:@"http:"];

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

opaqueview = [[UIView
alloc] initWithFrame: CGRectMake(x, x, x, x)];        //opaqueview    .h        
   UIActivityIndicatorView   view;

activityIndicator = [[UIActivityIndicatorView alloc] 
initWithFrame: CGRectMake(x, x, x, x)];//   .h       

[ activityIndicatorsetCenter: opaqueview.center];

[activityIndicator
setActivityIndicatorViewStyle:
UIActivityIndicatorViewStyleWhite]; //             

[opaqueview setBackgroundColor:[UIColor blackColor]];

[opaqueview setAlpha:0.6];

[self. viewaddSubview: opaqueview];

[opaqueview addSubview: activityIndicator];

     

- (void )webViewDidFinishLoad:(UIWebView *)webView 
{

[activityIndicator stopAnimating];

opaqueview.hidden  = YES ;

}

- (void )webViewDidStartLoad:(UIWebView *)webView 
{    

[ activityIndicator startAnimating];

opaqueview.hidden  = NO ;

}

         UIWebView       ,            

좋은 웹페이지 즐겨찾기