标签:ios objective-c
详见注释哈!
- (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 objective-c
原文地址:http://blog.csdn.net/liyakun1990/article/details/40297941