您的位置:首页 > 其它

ActivityIndicatorView和ProgressView

2015-11-07 21:20 507 查看

ActivityIndicatorView和ProgressView

- (IBAction)upload:(UIButton *)sender {
//开始和暂停
if ([self.activityIndicatorView isAnimating]) {
[self.activityIndicatorView stopAnimating];
}else{
[self.activityIndicatorView startAnimating];
}
}
- (IBAction)download:(UIButton *)sender {
//开启一个定时器 间隔1.0
myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(download) userInfo:nil repeats:YES];
}

- (void)download{
//没一秒递进0.1
self.progressView.progress += 0.1;
if (self.progressView.progress == 1.0) {
[myTimer invalidate];
//完成后让定时器失效  然后显示一个弹出框
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];

// Create the actions.
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"The \"Okay/Cancel\" alert's cancel action occured.");
}];

UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"other" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"The \"Okay/Cancel\" alert's other action occured.");
}];

// Add the actions.
[alertController addAction:cancelAction];
[alertController addAction:otherAction];

[self presentViewController:alertController animated:YES completion:nil];
}
}


自从8.0之后不推荐使用UIAlertView

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: