[Objective-C] IOS系统中网络等待的Loading的实现方法 →→→→→进入此内容的聊天室

来自 , 2020-10-04, 写在 Objective-C, 查看 161 次.
URL http://www.code666.cn/view/6f5e4e86
  1.  
  2. //创建UIWebView
  3. WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)];
  4. [WebView setUserInteractionEnabled:NO];
  5. [WebView setBackgroundColor:[UIColor clearColor]];
  6. [WebView setDelegate:self];
  7. [WebView setOpaque:NO];//使网页透明
  8.  
  9. NSString *path = @"http://www.baidu.com";
  10. NSURL *url = [NSURL URLWithString:path];
  11. [WebView loadRequest:[NSURLRequest requestWithURL:url]];
  12.  
  13. //创建UIActivityIndicatorView背底半透明View    
  14. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
  15. [view setTag:103];
  16. [view setBackgroundColor:[UIColor blackColor]];
  17. [view setAlpha:0.8];
  18. [self.view addSubview:view];
  19.  
  20. activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
  21. [activityIndicator setCenter:view.center];
  22. [activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
  23. [view addSubview:activityIndicator];
  24. [self.view addSubview:WebView];
  25. [view release];
  26. [WebView release];
  27.  
  28. //开始加载数据
  29. - (void)webViewDidStartLoad:(UIWebView *)webView {    
  30.       [activityIndicator startAnimating];        
  31. }
  32.  
  33. //数据加载完
  34. - (void)webViewDidFinishLoad:(UIWebView *)webView {
  35.      [activityIndicator stopAnimating];    
  36.      UIView *view = (UIView *)[self.view viewWithTag:103];
  37.      [view removeFromSuperview];
  38. }
  39.    
  40.  
  41.  
  42.  
  43.  
  44. //objectc/6861

回复 "IOS系统中网络等待的Loading的实现方法"

这儿你可以回复上面这条便签

captcha