开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜