Search code examples
iosiphoneuiactivityindicatorviewactivity-indicator

Can UIActivityIndicator be hidden?


So I'm trying to use a UIActivityIndicator when I am connecting to a web service. What I wanted to happen is to hide the activity indicator by default (eg. in viewDidLoad method) but I don't know how.

I only want to show the activity indicator and start its animation when a connection is ongoing between the app and the web service. When the connection is over, I want to hide the activity indicator again.

Is it possible?


Solution

  • You can stop and hide the activity indicator using the code:

    activityIndicator.hidden = YES;
    [activityIndicator stopAnimating];
    

    You can start and show the activity indicator by using:

    [activityIndicator startAnimating];
    activityIndicator.hidden = NO;