詳見注釋哈!
- (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];
}
}