zoukankan      html  css  js  c++  java
  • iOS之 UIWebView的简单学习

    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
  • 相关阅读:
    INSERT
    jQuery选择器
    工厂模式
    快乐的Linux命令行
    Linux常用命令与基本概念
    RAC 集群更换IP
    RMAN-03009 ORA-19504 ORA-27038
    Redhat 6.4_联网 yum 配置
    /dev/sda3: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY
    nginx安装笔记
  • 原文地址:https://www.cnblogs.com/wyhwyh2114/p/5063856.html
Copyright © 2011-2022 走看看