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];
    }


  • 相关阅读:
    【2017-03-09】SQL Server 数据库基础、四种约束
    【2017-03-05】函数基础、函数四种结构、ref和out参数、递归
    procecss on技巧
    角度与弧度
    C语言求π的方法
    三轴加速度传感器角度值转换原理
    C获取数组长度
    如何使用ProcessOn制作思维导图
    processon完全装逼指南
    NORDIC GATT事件
  • 原文地址:https://www.cnblogs.com/somethingWithiOS/p/6213957.html
Copyright © 2011-2022 走看看