Hide activity indicator

so in my main storyboard I created an activity indicator.

And I want to hide the activity indicator until a button is pressed. Is there any way I can do this?

Here is my code, when I click the button, the activity indicator starts animatig.

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

So, again the question is, can I hide the activity indicator until the button is pressed, and then it will show this activity indicator.

+6
source share
5 answers

, " ". , , , . , .

storyboard

+12

self.indicator.hidden = YES;

ViewDidLoad UIViewController " ".

+1

Swift 3 Xcode 8.3.2

actionIndicator viewDidLoad() hidesWhenStopped true.

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

, ActivityIndicator:

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

, :

self.activityIndicator.stopAnimating()
+1

, " " "" . "" , , .

0

swift, , , like-

@IBOutlet weak var indicator:UIActivityIndicatorView!{
     didSet{
          indicator.hidesWhenStopped = true
     }
}

, , hidesWhenStopped true, .

0

All Articles