首页 > 代码库 > 定时器和进度条(IOS开发)
定时器和进度条(IOS开发)
详见注释哈!
- (IBAction)startToMove:(id)sender { // 判断是否在旋转 // stopAnimating方法为停止动画效果 if ([self.myActivityIndicatorView isAnimating]) { [self.myActivityIndicatorView stopAnimating]; } else { [self.myActivityIndicatorView startAnimating]; } } - (IBAction)downloadProgress:(id)sender { // 定时器方法:在一个特定的时间间隔后向某对象发送消息 // target 为发送消息给哪个对象 // timeinterval 间隔时间 // selector 要调用的方法名 // userinfo 给消息发送的参数 // repeats 是否重复 myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(download) userInfo:nil repeats:YES]; } - (void)download{ self.myProgressView.progress += 0.1; // 设定步进长度 if (self.myProgressView.progress == 1.0) {// 如果进度条到头了 // 终止定时器 [myTimer invalidate]; // 弹出对话框 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"download completed!" message:@"Hey!Lucy!" delegate:nil cancelButtonTitle: @"OK!"otherButtonTitles:nil, nil]; [alert show]; } }
定时器和进度条(IOS开发)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。