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


  • 相关阅读:
    HTTP协议详解(真的很经典)
    几点建议,让Redis在你的系统中发挥更大作用
    Redis能干啥?细看11种Web应用场景
    Java中使用Jedis操作Redis
    java的锁机制——synchronized
    web开发中的两把锁之数据库锁:(高并发--乐观锁、悲观锁)
    一分钟教你知道乐观锁和悲观锁的区别
    $^,$@,$?,$<,$(@D),$(@F) of makefile
    linux shared lib 使用与编译
    makefile learning
  • 原文地址:https://www.cnblogs.com/somethingWithiOS/p/6213957.html
Copyright © 2011-2022 走看看