Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide activity indicator

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?

like image 945
Student Avatar asked Mar 04 '15 21:03

Student


People also ask

How do I get rid of the activity indicator?

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.

How do I hide my activity indicator in react native?

The animating prop is used to show and hide the activity indicator in react native. The animating prop support two values True(To Show ActivityIndicator ) and False (To Hide ActivityIndicator ).

How do I start activity indicator in Swift?

Enter Swift as Language and Storyboard as the User Interface. Choose Next. Go to the Storyboard and drag two buttons to the main view. Set the title of the buttons to "Start" and "Stop".


2 Answers

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

like image 135
Jose Manuel Abarca Rodríguez Avatar answered Oct 17 '22 19:10

Jose Manuel Abarca Rodríguez


Swift 3 Xcode 8.3.2

First hide your activityIndicator in viewDidLoad() method and set hidesWhenStopped property to true.

override func viewDidLoad(){
     super.viewDidLoad()
     self.activityIndicator.isHidden = true
     self.activityIndicator.hidesWhenStopped = true
}

Later when you want to show activityIndicator :

self.activityIndicator.isHidden = false
self.activityIndicator.startAnimating()

And when you want to stop it use :

self.activityIndicator.stopAnimating()
like image 5
Prashant Gaikwad Avatar answered Oct 17 '22 19:10

Prashant Gaikwad