zoukankan      html  css  js  c++  java
  • UIWebView with progress

     //progress@property (strong, nonatomic) UIProgressView *progressView;

    //timer to fresh progress
    @property (nonatomic,strong) NSTimer *myTimer;
    //sign web load status
    @property (nonatomic,assign) BOOL theBool;
    
    //when web start load initialization
    - (void)webViewDidStartLoad:(UIWebView *)webView{
         progressView.hidden = NO;
       myProgressView.progress = 0;
         theBool = false;
         //0.01667 is roughly 1/60, so it will update at 60 FPS
         myTimer = [NSTimer scheduledTimerWithTimeInterval:0.01667 target:self selector:@selector(timerCallback) userInfo:nil repeats:YES];
    }
    //when web load successfully , progress view hide
    - (void)webViewDidFinishLoad:(UIWebView *)webView{
         theBool = true;
    }
    //fresh progress view
    -(void)timerCallback {
        if (theBool) {
             if (myProgressView.progress >= 1) {
                  myProgressView.hidden = true;
                  [myTimer invalidate];
             }
             else {
                  myProgressView.progress += 0.1;
             }
        }
        else {
             myProgressView.progress += 0.05;
             if (myProgressView.progress >= 0.95) {
                  myProgressView.progress = 0.95;
             }
        }
    }
  • 相关阅读:
    Section 3.1 Shaping Regions
    3D@OpenSource
    查找资料
    Section 3.1 Shaping Regions Again
    USACO Contact IOI’98 TLE
    事项ON丰宁坝上草原
    四叉树@POJ1610 Quad Trees
    在TabCtrl上放View@MFC
    CUGB的一场周赛
    贴图程序进展
  • 原文地址:https://www.cnblogs.com/helmsyy/p/5318915.html
Copyright © 2011-2022 走看看