中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

iOS應用中網(wǎng)絡等待Loading的實現(xiàn)方法

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用

UIWebView加載Loading...兩種方法

第一種方法:使用UIView and UIActivityIndicatorView

//創(chuàng)建UIWebView
WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)];
[WebView setUserInteractionEnabled:NO];
[WebView setBackgroundColor:[UIColor clearColor]];
[WebView setDelegate:self];
[WebView setOpaque:NO];//使網(wǎng)頁透明

NSString *path = @"http://www.baidu.com";
NSURL *url = [NSURL URLWithString:path];
[WebView loadRequest:[NSURLRequest requestWithURL:url]];

//創(chuàng)建UIActivityIndicatorView背底半透明View    
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[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];

//開始加載數(shù)據(jù)
- (void)webViewDidStartLoad:(UIWebView *)webView {    
      [activityIndicator startAnimating];         
}

//數(shù)據(jù)加載完
- (void)webViewDidFinishLoad:(UIWebView *)webView {
     [activityIndicator stopAnimating];    
     UIView *view = (UIView *)[self.view viewWithTag:103];
     [view removeFromSuperview];
}

  第二種方法:使用UIAlertView and UIActivityIndicatorView
/加載網(wǎng)頁動畫
- (void)webViewDidStartLoad:(UIWebView *)webView{
    if (myAlert==nil){        
       myAlert = [[UIAlertView alloc] initWithTitle:nil 
                                                              message: @"讀取中..."
                                                                delegate: self
                                                 cancelButtonTitle: nil
                                                 otherButtonTitles: nil];

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

- (void)webViewDidFinishLoad:(UIWebView *)webView{ 
      [myAlert dismissWithClickedButtonIndex:0 animated:YES];
}

標簽:

版權申明:本站文章部分自網(wǎng)絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:Android 獲取SD卡路徑和空間使用情況

下一篇:Android獲得當前安裝的所有應用程序列表