UIwebView 之初体验。。。。。

1.首先创建webView 设置坐标已经大小

UIWebView *webView = [[UIWebView alloc]init];

  webView.frame = CGRectMake(0, iOS7 ? 0: 64, DCS_SCREEN_W, DCS_SCREEN_H-(iOS7?0:64));

2.设置屏幕的自适应  让webview能适应屏幕的大小

//屏幕的自适应
    webView.scalesPageToFit = [self isNeedFit];
    webView.backgroundColor = [UIColor whiteColor];

3.设置webView的代理 以及autoresizing  然后添加到view上

webView.delegate = self;
 webView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);

[self.view addSubview:webView];

4.设置网络请求 然后load请求

 //2.0 请求
    NSURL *url =[NSURL URLWithString:[DCSURLUtils urlWithAbout]];
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    
    [self.webView loadRequest:request];

5.设置展示的东西

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

    

你可能感兴趣的:(webView)