如何在我的应用中使用nstimer设置活动指示器。
提前致谢:
答案 0 :(得分:1)
在头文件中,您需要声明活动指标和活动计时器。
- (void)viewDidLoad {
[super viewDidLoad];
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.frame = CGRectMake(150,200, 20, 20);
[self.view addSubview:activityIndicator];
[activityIndicator startAnimating];
[activityTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(stopActivity:) userInfo:nil repeats:NO];
[activityIndicator release];
}
-(void) stopActivity:(NSTimer *) theTimer
{
[activityIndicator stopAnimating];
[activityTimer invalidate];
activityTimer = nil;
}