IOS开发学习笔记-(3) 进度条、等待动画开始停止
来源:互联网 发布:智能机锁屏软件 编辑:程序博客网 时间:2024/06/14 16:06
一、创建对应空间视图 ,如下图:
二、编写对应的 .h 代码,如下 :
#import <UIKit/UIKit.h>@interface ViewController : UIViewController@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activWaitNetWork;@property (weak, nonatomic) IBOutlet UIProgressView *pgrsDownLoad;@property (weak,nonatomic) NSTimer *timer;- (IBAction)onclickStartRequest:(id)sender;- (IBAction)onclickDownLoad:(id)sender;@end
三、编写对应的 .m 文件的实现,注释比较详细:
#import "ViewController.h"@interface ViewController ()@end@implementation ViewController@synthesize activWaitNetWork;@synthesize pgrsDownLoad;@synthesize timer;- (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.}- (IBAction)onclickStartRequest:(id)sender{ //如果正在运行,停止; 否则 开始运行加载 if ([activWaitNetWork isAnimating]) { [activWaitNetWork stopAnimating]; }else{ [activWaitNetWork startAnimating]; }}- (IBAction)onclickDownLoad:(id)sender{ //重新开始进度 pgrsDownLoad.progress = 0; //定时任务 跟新 Progerss 的进度 timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(update) userInfo:nil repeats:YES]; }- (void)update{ pgrsDownLoad.progress = pgrsDownLoad.progress + 0.1 ; //当进度完成时,提示下载完成 if(pgrsDownLoad.progress == 1){ [timer invalidate]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"文件下载完成" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil ]; [alert show]; } }- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
四、运行效果 ,如下:
代码地址 : http://download.csdn.net/detail/jiangtao_st/7684965
0 0
- IOS开发学习笔记-(3) 进度条、等待动画开始停止
- 【代码笔记】iOS-等待动画
- 【iOS开发-9】UIImage和UIImageView属性介绍,实现图片动画,实现开始/停止按钮效果
- iOS开发UIImage和UIImageView属性介绍,实现图片动画,实现开始/停止按钮效果
- iOS开发-简单动画笔记
- iOS开发 -- imageView (动画) UISlider进度条(滑块)
- 开始学习iOS开发啦~
- iOS学习笔记-核心动画
- iOS 学习笔记 UIView动画
- Android应用开发学习笔记之进度条
- iOS 自定义加载等待动画
- ios如何获得停止动画
- IOS 等待控件ActicityIndicator与进度条ProgressView
- 安卓动画开始,暂停和停止
- iOS开发13-iOS动画的学习
- ios-cocos2d游戏开发基础-进度条-开发笔记
- 开始学习 IOS 开发,学习环境搭建
- WebView学习笔记(一)——网页未完成加载的等待进度条
- Linux应用程序开发笔记->文件编程之库函数
- 多重继承和虚基类
- CSS中的长度问题-------Day76
- mac jdk配置
- tomcat配置虚拟主机
- IOS开发学习笔记-(3) 进度条、等待动画开始停止
- Atitit.列表页面and条件查询的实现最佳实践(1)------设置查询条件and提交查询and返回json数据
- 分治法(Scheme) -- 快速排序
- at&T语法格式
- HDR Image encoding formats
- 一周小节
- Linux命令exit - 退出当前shell
- HDOJ题目2086 A1 = ?(数学)
- .net mvc 微信开发笔记(五)------JSON解析,自定义菜单