Hide activity indicator

Student picture Student · Mar 4, 2015 · Viewed 11.9k times · Source

On my main storyboard I created an Activity Indicator.

I want to hide my activity indicator until the button has been pressed. Is there a way I can do that?

When I press the button the activity indicator starts animating.

self.indicator.hidden = NO;
[self.indicator startAnimating];
[self performSelector:@selector(showData) withObject:nil afterDelay:2.0f];

Can I hide the activity indicator until the button has been pressed, and then show this activity indicator?

Answer

Select the Activity Indicator in Storyboard, then select property "Hides when stopped". This way you don't have to hide it, just start or stop the animation, and the Activity Indicator will show and hide automatically. Of course, you still have to add the code to start and stop the animation to buttons.

storyboard