zoukankan      html  css  js  c++  java
  • iOS UIWebView加载时添加进度条01

    标注:此框架仅适合UIWebView  对iOS8后新出的WKWebView不适用,当然,你可以尝试修改框架里的几个代理方法。

    框架是:NJKWebViewProgress

    导入头文件

    #import "NJKWebViewProgressView.h"
    #import "NJKWebViewProgress.h"


    @implementation XFHelpCenterViewController
    {
        NJKWebViewProgressView *_progressView;
        NJKWebViewProgress *_progressProxy;
    }

    - (void)viewWillAppear:(BOOL)animated{
        
        [super viewWillAppear:animated];
        [self.navigationController.navigationBar addSubview:_progressView];
    }

    -(void)viewWillDisappear:(BOOL)animated{
        
        [super viewWillDisappear:animated];
        [_progressView removeFromSuperview];
    }


    初始化

    -(void)initViews{
        XFUserModel* userModel = [NSKeyedUnarchiver unarchiveObjectWithFile:[NSString userDataPathWithPath:@"userIfor.data"]];
        LGFLog(@"%@",userModel.help);
        NSURL *URL = [NSURL URLWithString:userModel.help];
        _webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
        [_webView loadRequest:[NSURLRequest requestWithURL:URL]];
        [self.view addSubview:_webView];
    }


    -(void)setProgress{
        
        _progressProxy = [[NJKWebViewProgress alloc] init];
        self.webView.delegate = _progressProxy;
        _progressProxy.webViewProxyDelegate = self;
        _progressProxy.progressDelegate = self;
        
        CGFloat progressBarHeight = 1.f;
        CGRect navigationBarBounds = self.navigationController.navigationBar.bounds;
        CGRect barFrame = CGRectMake(0, navigationBarBounds.size.height - progressBarHeight, navigationBarBounds.size.width, progressBarHeight);
        _progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
        _progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
    }


    代理方法

    #pragma mark - NJKWebViewProgressDelegate
    -(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress{
        
        [_progressView setProgress:progress animated:YES];
    }


  • 相关阅读:
    在eclipse中使用maven构建spring cloud微服务
    SpringBoot中VO,DTO,DO,PO的概念、区别和用处
    报错Connection refused: connect
    @RequestBody的使用
    Chrome插件Postman的数据目录存储位置,记一次重装系统后找回postman数据的过程...
    SpringBoot中VO,DTO,DO,PO的概念、区别和用处
    Oracle中的instr()函数 详解及应用
    for循环里的break,continue和return有什么差别
    BigDecimal转String
    字符串转为日期,日期转为字符串
  • 原文地址:https://www.cnblogs.com/somethingWithiOS/p/6213957.html
Copyright © 2011-2022 走看看