How to set Activity indicator with timer
How can i set activity in开发者_运维问答dicator with nstimer in my apps.
Thanks in Advance:
In header file you need to declare activityIndicator and activityTimer.
- (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;
}
精彩评论