• 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
  • 相关阅读:
    ubuntu下Nodic开发环境搭建
    usb_modeswitch移植
    STM32F4编程手册学习2_内存模型
    STM32F4 编程手册学习1_编程模型
    ARM架构中的程序执行与调用
    锲形文字 数字
    疑问
    lisp 题目
    面试官在面试时让我去破解一个软件,我成功了
    php CI ip限制
  • 原文地址:https://www.cnblogs.com/wyhwyh2114/p/5063856.html
Copyright © 2020-2023  润新知