iOS之 UIWebView的簡單學習

來源:互聯網
上載者:User

標籤:

UIWebView的簡單學習

 

 

 

 

#import "ViewController.h"@interface ViewController ()<UIWebViewDelegate>{    UIWebView  *WebView;    UIView     *view;    UIActivityIndicatorView *activityIndicator;}@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    self.view.backgroundColor = [UIColor whiteColor];    WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)];    [WebView setUserInteractionEnabled:NO];//是否支援互動    [WebView setBackgroundColor:[UIColor clearColor]];    [WebView setDelegate:self];//委託    [WebView setOpaque:NO];//使網頁透明(Opaque為不透明的意思,這裡為透明)        //載入網頁的方法    //1.建立並載入遠程網頁    NSString *path = @"http://www.baidu.com";    NSURL *url = [NSURL URLWithString:path];    [WebView loadRequest:[NSURLRequest requestWithURL:url]];        //建立UIActivityIndicatorView背底半透明View    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];        }    //開始載入資料    - (void)webViewDidStartLoad:(UIWebView *)webView {        [activityIndicator startAnimating];    }        //資料載入完    - (void)webViewDidFinishLoad:(UIWebView *)webView {        [activityIndicator stopAnimating];    }- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end

 

iOS之 UIWebView的簡單學習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.