码迷,mamicode.com
首页 > 移动开发 > 详细

iOS.UIKit.06.UIProgressView_UIActivityIndicatorView

时间:2014-06-04 16:25:07      阅读:366      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

一、案例介绍:点击按钮upload,活动指示器转动,再次点击停止转动;点击download按钮进度条加载满后提示,如图01,图02。

bubuko.com,布布扣图01bubuko.com,布布扣图02

二、案例步骤:

1、选择Simple View Aplication,取名cq.31.活动指示器和进度条,如图03。

bubuko.com,布布扣图03

2、Main.storyboard,如图04,图05。

bubuko.com,布布扣图04bubuko.com,布布扣图05

3、CQ31ViewController.h

bubuko.com,布布扣
#import <UIKit/UIKit.h>

@interface CQ31ViewController : UIViewController
{
    NSTimer *myTimer;
}
@property(nonatomic,strong) NSTimer *myTimer;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *myActivityIndicatorView;
@property (weak, nonatomic) IBOutlet UIProgressView *myProgressView;


- (IBAction)startToMove:(id)sender;
- (IBAction)downloadProgress:(id)sender;

@end
bubuko.com,布布扣

 

4、CQ31ViewController.m

bubuko.com,布布扣
#import "CQ31ViewController.h"

@interface CQ31ViewController ()

@end

@implementation CQ31ViewController
@synthesize myTimer;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)startToMove:(id)sender
{
    if ([self.myActivityIndicatorView isAnimating]) {
        [self.myActivityIndicatorView stopAnimating];
    }else{
        [self.myActivityIndicatorView startAnimating];
    }
}

- (IBAction)downloadProgress:(id)sender
{
    myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(download) userInfo:nil repeats:YES];
}

- (void)download
{
    self.myProgressView.progress=self.myProgressView.progress+0.1;
    if (self.myProgressView.progress==1.0) {
        [myTimer invalidate];
        UIAlertView*alert=[[UIAlertView  alloc]initWithTitle:@"download completed!"
                                                     message:@""
                                                    delegate:nil
                                           cancelButtonTitle:@"OK"
                                           otherButtonTitles: nil];
        [alert show];
    }
}

@end
bubuko.com,布布扣

 

 

iOS.UIKit.06.UIProgressView_UIActivityIndicatorView,布布扣,bubuko.com

iOS.UIKit.06.UIProgressView_UIActivityIndicatorView

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/cqchen/p/3764864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!