活动指示器ActivityIndicatorView和进度条ProgressView
来源:互联网 发布:od软件 编辑:程序博客网 时间:2024/06/11 02:26
ActivityIndicatorView可以消除用户的心理等待时间,ProgressView可以指示请求的进度,也有消除用户心理等待时间的作用。
其中在ActivityIndicatorView中,重要的方法:isAnimating方法用于判断ActivityIndicatorView是否处于运动状态,stopAnimating方法用于停止旋转,startAnimating方法用于开始旋转。
进度条中用到了定时器NSTimer的方法scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(bool)repeats,其中second参数设置时间间隔,target用于指定发送消息给那个对象,aSelector指定要调用的方法名,相当于一个函数指针,userInfo可以给消息发送参数,repeats表示是否重复。
实例代码如下:
//
// ViewController.h
// 1006ActivityIndicatorViewAndProgressViewSample
//
// Created by weibiao on 15-10-6.
// Copyright (c) 2015年 weibiao. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
NSTimer *myTimer;
}
//活动只是其的输出口
@property (weak, nonatomic) IBOutletUIActivityIndicatorView *activityIndicator;
//活动指示器的方法
- (IBAction)upload:(id)sender;
//进度条的输出口
@property (weak, nonatomic) IBOutletUIProgressView *myProgressView;
//进度条的方法
- (IBAction)download:(id)sender;
@end
//
// ViewController.m
// 1006ActivityIndicatorViewAndProgressViewSample
//
// Created by weibiao on 15-10-6.
// Copyright (c) 2015年 weibiao. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()<UIAlertViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)upload:(id)sender {
if ([self.activityIndicatorisAnimating]) {
[self.activityIndicatorstopAnimating];
} else {
[self.activityIndicatorstartAnimating];
}
}
- (IBAction)download:(id)sender {
myTimer = [NSTimerscheduledTimerWithTimeInterval:1.0target:selfselector:@selector(download)userInfo:nilrepeats:YES];
}
- (void)download {
self.myProgressView.progress =self.myProgressView.progress +0.1;
if (self.myProgressView.progress ==1.0) {
[myTimer invalidate];
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"download complete"message:@""delegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil];
[alert show];
}
}
@end
- 活动指示器ActivityIndicatorView和进度条ProgressView
- 159,活动指示器ActivityIndicatorView和进度条ProgressView
- UI组件:ProgressView进度条
- iOS 绘制下载进度条progressView
- javafX8初探(进度条和进度指示器)
- NSTimer与ProgressView进度条的使用
- IOS 等待控件ActicityIndicator与进度条ProgressView
- iOS 自定义控件 progressView(环形进度条)
- iOS 自定义控件 progressView(环形进度条)
- swift UI专项训练16 ProgressView进度条
- iOS 自定义控件 progressView(环形进度条)
- progressview
- UIActivityIndicatorView活动指示器
- UIActivityIndicatorView-----------活动指示器
- UIActivityIndicatorView 活动指示器
- UIActivityIndicatorView活动指示器
- UIActivityIndicatorView活动指示器
- 活动指示器(UIActivityIndicatorView)
- iOS masonry进行页面适配
- com.mysql.jdbc.MysqlDataTruncation: Data truncation异常
- iOS M3U8视频的下载与播放
- 新建SVN仓库设置
- iOS coredata的使用及版本升级
- 活动指示器ActivityIndicatorView和进度条ProgressView
- iOS block传值
- 建枚举类时出现“Project '**' is not a J2SE 5.0 compliant project.”问题怎么办?
- iOS 百度地图
- 线段树 csu1555 Inversion Sequence
- 第一章 java前奏
- 《Python基础教程 第2版·修订版》第3章 使用字符串(学习笔记)
- Java版线性表的链式存储和实现
- iOS 高德地图