• 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

     

  • 相关阅读:
    Kibana之配置文件
    Elasticsearch之集群,本地搭建集群
    支付宝支付流程
    AJAX应用的五个步骤
    位运算
    微信小程序页面传值详解
    面向对象三大基本特性,五大基本原则
    rem样板
    js 数组 随机排序
    按位异或运算符
  • 原文地址:https://www.cnblogs.com/csj007523/p/2581595.html
Copyright © 2020-2023  润新知