Activity indicator for 5seconds?

Navi picture Navi · May 31, 2013 · Viewed 7.1k times · Source

All

I am trying to run UIActivityIndicator for a 5 seconds on viewdidappear method .But how do i give a time limit for activity indicator(5 seconds) ?

This is the code for UIActivityIndicator

 UIActivityIndicatorView *activityView=[[UIActivityIndicatorView alloc]     initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    activityView.center=self.view.center;

    [activityView startAnimating];

    [self.view addSubview:activityView];

Answer

Alexander picture Alexander · May 31, 2013

With one line and no additional dependencies & conditions:

[activityView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:5.0];