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

     

  • 相关阅读:
    【PyQt5-Qt Designer】对话框系列
    【PyQt5-Qt Designer】界面布局
    【PyQt5-Qt Designer】PyQt5+eric6 安装和配置
    【PyQt5-Qt Designer】QMessageBox 弹出框总结
    【PyQt5-Qt Designer】鼠标+键盘事件
    【PyQt5-Qt Designer】猜数字(小项目)
    【PyQt5-Qt Designer】浅谈关闭窗口
    【PyQt5-Qt Designer】窗口操作
    【python基础】利用pandas处理Excel数据
    【python基础】os.path模块常用方法详解
  • 原文地址:https://www.cnblogs.com/csj007523/p/2581595.html
Copyright © 2011-2022 走看看