Set the type of activity to automatically hide when stopped
activityView.hidesWhenStopped = YES;
And hide it after 5s as follows:
[activityView performSelector:@selector(stopAnimating) withObject:nil afterDelay:5.0]
This will allow you to start the animation again just by calling startAnimating if you need it in the future and keep a pointer to the UIActivityIndicatorView
If you just need to show the activity indicator once and will no longer use it, Alexanders answer best suits your needs.
source share