zoukankan      html  css  js  c++  java
  • IOS UIProgressView 用法

    UIProgressView:

     作用:

    动态显示当前工作状态进度。

    progressView

    Progress bar view

    1.h file

    //  Created by denny chen on 12-7-8.

    //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.

    //


    #import <UIKit/UIKit.h>


    @interface ProgressViewViewController : UIViewController

    {

        UIProgressView *progressview;

        UIProgressView *barprogressview;

        NSTimer *timer;

        IBOutlet UIButton *startButton;

        IBOutlet UIButton *stopButton; 

    }


    @property (nonatomic,retain) IBOutlet UIProgressView *progressview;

    @property (nonatomic,retain) IBOutlet UIProgressView *barprogressview;

    -(IBAction) startProgress:(id)sender;

    -(IBAction) stopProgress:(id)sender;


    @end

    2 .m file

    @implementation ProgressViewViewController


    @synthesize progressview;

    @synthesize barprogressview;


    - (void)viewDidLoad

    {

        self.progressview=nil;

        self.barprogressview=nil;

        [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

        stopButton.enabled = NO;

        startButton.enabled = YES; 

    }


    -(void) dealloc

    {

        self.progressview=nil;

        self.barprogressview=nil;

        

        [super dealloc];

    }


    - (void)viewDidUnload

    {

        self.progressview=nil;

        self.barprogressview=nil;

        [super viewDidUnload];

        // Release any retained subviews of the main view.

    }



    /*进度条每次加0.01 */

    -(void) timerChanged:(id)sender

    {

        self.progressview.progress +=0.01f;

        self.barprogressview.progress +=0.01f;

    }


    -(IBAction) startProgress:(id)sender

    {

        

        timer=[NSTimer scheduledTimerWithTimeInterval:0.03f

                                             target:self 

                                             selector:@selector(timerChanged:) 

                                             userInfo:nil 

                                             repeats:YES];

         //[timer retain];

          startButton.enabled = NO;

        stopButton.enabled = YES;

    }

    -(IBAction) stopProgress:(id)sender

    {

        [timer invalidate];

        //[timer release];

        //timer =nil;

        

        self.progressview.progress=0.0f;

        self.barprogressview.progress=0.0f;

         startButton.enabled = YES;

        stopButton.enabled = NO;

    }

    3 run reslut

     

  • 相关阅读:
    500桶酒中有一桶毒酒
    查看docker run参数(亲测实用)
    ubuntu密码忘记-备份
    python sklearn2pmml
    javafx弹窗显示错误堆栈
    Java实现新开一个进程
    MockServer调试通过,本地通过浏览器可以打开对应web网页
    java 实现Put request
    JAVA发送HttpClient请求及接收请求完整代码实例
    我还是很喜欢你
  • 原文地址:https://www.cnblogs.com/csj007523/p/2581595.html
Copyright © 2011-2022 走看看